>你这是指定文件夹名呀,问题是我这里有百十个文件夹,要一个个指定名字就太费劲了,有没有自动获取的办法
这需要 2 个 For
@echo off
for /f %%i in ('dir d:\ /ad /b') do (
@echo %%~fi
echo for /r
详情回复
发表于 2022-2-12 22:26
@echo off
for /r d:\a %%a in (*.jpg *.doc) do if exist "%%a" move /y "%%a" d:\a
for /r d:\b %%a in (*.jpg *.doc) do if exist "%%a" move /y "%%a" d:\b
for /r d:\c %%a in (*.jpg *.doc) do if exist "%%a" move /y "%%a" d:\c
for /f "delims=" %%i in ('dir d:\a /ad /b /s ^|sort /r') do (
rd "%%i">nul 2>nul &&if not exist %%i\ echo 成功删除:%%i
)
for /f "delims=" %%i in ('dir d:\b /ad /b /s ^|sort /r') do (
rd "%%i">nul 2>nul &&if not exist %%i\ echo 成功删除:%%i
)
for /f "delims=" %%i in ('dir d:\c /ad /b /s ^|sort /r') do (
rd "%%i">nul 2>nul &&if not exist %%i\ echo 成功删除:%%i
尝试改成这样
@echo off
for /d %%b in (*) do (
for /r %%a in (*.jpg *.doc) do if exist "%%a" move /y "%%a" "%%b\"
)
pause
结果都给弄到最后一个文件夹里去了
详情回复
发表于 2022-2-12 22:03
你先弄个 虚拟盘 或 虚拟机 测试,避免发生悲剧.
未测试,思路推论修改.
@echo off
for /r d:\a %%a in (*.jpg *.doc) do if exist "%%a" move /y "%%a" d:\a
for /r d:\b %%a in (*.jpg *.doc) do if exist "%%
详情回复
发表于 2022-2-12 21:55