set varDir= %~dp0 set varTimeTemp1=%time: =0% set varTimeTemp2=%varTimeTemp1::=% set varTime=%varTimeTemp2:~0,6% set varDate=%date:~0,4%%date:~5,2%%date:~8,2%%varTime%
if /i "%GTOperator%"=="1" goto GTExit if /i "%GTOperator%"=="2" goto GTDIRFILEPATH if /i "%GTOperator%"=="3" goto GTDIRPATH if /i "%GTOperator%"=="4" goto GTFILEPATHCUSTOMFORMAT if /i "%GTOperator%"=="5" goto GTDIRFILENAME if /i "%GTOperator%"=="6" goto GTDIRNAME if /i "%GTOperator%"=="7" goto GTFILESNAME if /i "%GTOperator%"=="8" goto GTDIRNAMECURRENT if /i "%GTOperator%"=="9" goto GTFILESNAMECURRENT if /i "%GTOperator%"=="0" goto GTBegin
echo 输入正确的操作编号 pause >nul goto GTCONTINUE
:GTDIRFILEPATH set ListFileName=所有目录和文件路径 set LISTFilePath=%varDir%%ListFileName%-%varDate%.txt @echo 需要一点时间,请耐心等待... for /f "delims=" %%ain ('dir /b /s "%HandleDir%"') doecho%%~a >> %LISTFilePath% ifnotexist%LISTFilePath%goto GTNODOC :: echo 完成操作 start%LISTFilePath% :: pause >nul goto GTCONTINUE
:GTDIRPATH set ListFileName=所有目录 set LISTFilePath=%varDir%%ListFileName%-%varDate%.txt @echo 需要一点时间,请耐心等待... for /f "delims=" %%ain ('dir /ad /b /s "%HandleDir%"') doecho%%~a >> %LISTFilePath% ifnotexist%LISTFilePath%goto GTNODOC :: echo 完成操作 start%LISTFilePath% :: pause >nul goto GTCONTINUE
:GTFILEPATHCUSTOMFORMAT @ set /p FileExtension="文件扩展名(*.jpg/*.gif/*.png/*.mp4/*.mp3/*.exe/*.txt …):" set ListFileName=指定格式的文件路径 set LISTFilePath=%varDir%%ListFileName%-%varDate%.txt @echo 需要一点时间,请耐心等待... for /f "delims=" %%ain ('dir /b /s "%HandleDir%"%FileExtension%') doecho%%~a >> %LISTFilePath% ifnotexist%LISTFilePath%goto GTNODOC :: echo 完成操作 start%LISTFilePath% :: pause >nul goto GTCONTINUE
:GTDIRFILENAME set ListFileName=所有目录和文件名 set LISTFilePath=%varDir%%ListFileName%-%varDate%.txt @echo 需要一点时间,请耐心等待... for /f "delims=" %%ain ('dir /b /s "%HandleDir%"') doecho%%~nxa >> %LISTFilePath% ifnotexist%LISTFilePath%goto GTNODOC :: echo 完成操作 start%LISTFilePath% :: pause >nul goto GTCONTINUE
:GTDIRNAME set ListFileName=所有目录名 set LISTFilePath=%varDir%%ListFileName%-%varDate%.txt @echo 需要一点时间,请耐心等待... for /f "delims=" %%ain ('dir /ad /b /s "%HandleDir%"') doecho%%~nxa >> %LISTFilePath% ifnotexist%LISTFilePath%goto GTNODOC :: echo 完成操作 start%LISTFilePath% :: pause >nul goto GTCONTINUE
:GTFILESNAME set ListFileName=所有文件名 set LISTFilePath=%varDir%%ListFileName%-%varDate%.txt @echo 需要一点时间,请耐心等待... for /f "delims=" %%ain ('dir /a-d /b /s "%HandleDir%"') doecho%%~nxa >> %LISTFilePath% ifnotexist%LISTFilePath%goto GTNODOC :: echo 完成操作 start%LISTFilePath% :: pause >nul goto GTCONTINUE
:GTDIRNAMECURRENT set ListFileName=当前层级目录名 set LISTFilePath=%varDir%%ListFileName%-%varDate%.txt @echo 需要一点时间,请耐心等待... for /f "delims=" %%ain ('dir /ad /b "%HandleDir%"') doecho%%~nxa >> %LISTFilePath% ifnotexist%LISTFilePath%goto GTNODOC :: echo 完成操作 start%LISTFilePath% :: pause >nul goto GTCONTINUE
:GTFILESNAMECURRENT set ListFileName=当前层级文件名 set LISTFilePath=%varDir%%ListFileName%-%varDate%.txt @echo 需要一点时间,请耐心等待... for /f "delims=" %%ain ('dir /a-d /b "%HandleDir%"') doecho%%~nxa >> %LISTFilePath% ifnotexist%LISTFilePath%goto GTNODOC :: echo 完成操作 start%LISTFilePath% :: pause >nul goto GTCONTINUE