小白求个bat
bat吧
全部回复
仅看楼主
level 2
目前我有一个12月的文件夹,里面有12-01到12-31的文件夹,只有12-01到12-16的文件夹里有文件,想在12月的文件夹里面用一个bat实现将所有子文件夹里的文件的目录输出成子文件夹名字的txt(例如:在12-01文件夹下生成12-01.txt,12-02则生成12-02.txt),如果子文件夹里面没文件刚不生成txt,如何写,
我只会在子文件夹里面放一个bat,生成一个固定的名字!万分感谢!
2022年12月23日 19点12分 1
level 1
@@echo off
set "tmp1=%Temp%\tmp1.tmp"
set "tmp2=%Temp%\tmp2.tmp"
if exist "%tmp1%" del /s /q /f "%tmp1%">nul
if exist "%tmp2%" del /s /q /f "%tmp2%">nul
dir /d /b /a:d>>"%tmp1%"
for /f "delims=" %%a in (%tmp1%) do (
rd %%a -q>nul 2>nul
)
dir /d /b /a:d>>"%tmp2%"
for /f "delims=" %%i in (%tmp2%) do (
set "content=%%i"
echo off>%%i\%%i.txt
)
for /f "delims=" %%j in (%tmp1%) do (
set "content1=%%j"
mkdir %%j>nul 2>nul
)
2022年12月26日 02点12分 3
2022年12月26日 02点12分
大佬你好,我用你的命令试了下,能生成txt,子文件夹有文件,但是打开是空的
2023年01月02日 21点01分
level 9
for /f "tokens=*" %%a in ('dir /a-d/b "%~dp0"') do for /f "tokens=*" %%b in ('dir /s "%~dp0%%~a\"') do echo.%%b>>"%~dp0%%~a\%%a.txt"
2023年01月23日 21点01分 5
1