bat脚本获目录下下的文件名称:dir tree

bat脚本获目录下下的文件名称:dir tree
bat脚本获目录下下的文件名称:dir tree
1。名称.bat
@echo off

:获取对应路径下文件名,
DIR /S/N >a.txt

pause
bat脚本获目录下下的文件名称:dir tree
2。名称进阶版.bat

@echo off

if exist list.txt del list.txt /q
:input
cls
set input=:
set /p input=Please input path:
set “input=%input:”=%"
:: 上面这句为判断%input%中是否存在引号,有则剔除。
if “%input%”":" goto input
if not exist “%input%” goto input
for %%i in ("%input%") do if /i “%%~di”
%%i goto input
pushd %cd%
cd /d “%input%”>nul 2>nul || exit
set cur_dir=%cd%

popd
:: %%~nxi只显示文件名,%%i显示带路径的文件信息
for /f “delims=” %%i in (‘dir /b /a-d /s “%input%”’) do echo %%i>>list.txt
if not exist list.txt goto no_file
start list.txt
exit

:no_file
cls
echo %cur_dir% Folder does not have a separate document

pause
bat脚本获目录下下的文件名称:dir treebat脚本获目录下下的文件名称:dir tree

3。
@ECHO OFF

tree /f C:\Users\Administrator\Desktop\CDA文档20200702 > 文件树.txt

pause
bat脚本获目录下下的文件名称:dir tree

4。
@echo off
if exist 文件树1.txt del 文件树1.txt /q
:input
cls
set input=:
set /p input=Please input path:
set “input=%input:”=%"
:: 上面这句为判断%input%中是否存在引号,有则剔除。
if “%input%”":" goto input
if not exist “%input%” goto input
for %%i in ("%input%") do if /i “%%~di”
%%i goto input
pushd %cd%
cd /d “%input%”>nul 2>nul || exit
set cur_tree=%cd%
popd
:: %%~nxi只显示文件名,%%i显示带路径的文件信息
for /f “delims=” %%i in (‘tree /f “%input%”’) do echo %%i>>文件树1.txt
if not exist list.txt goto no_file
start list.txt
exit

:no_file
cls
echo %cur_tree% Folder does not have a separate document
pause

bat脚本获目录下下的文件名称:dir tree