批处理文件,用于自动从树中删除指定的文件夹

时间:2018-11-26 17:39:26

标签: windows batch-file cmd rmdir

我正在尝试编写一个简单的工具来从Windows系统中删除垃圾Mac文件,但是,由于指定的文件夹(.fseventsd)仍然存在,因此我遇到了麻烦。下面是批处理文件,并且需要关注的特定区域是:.fseventsd部分中的rmdir命令。

rem @echo off
cls
cd \

:.fseventsd
echo Searching for '.fseventsd' folders.
rmdir /S /Q ".fseventsd" 2> nul
if errorlevel 1 echo No '.fseventsd' folders were found.
goto :.DS_STORE
if errorlevel 0 echo All '.fseventsd' folders have been deleted.

:.DS_STORE
echo.
echo Searching for '.DS_STORE' files.
del /s /q /f /a:rash .DS_STORE 2> nul
if errorlevel 1 echo No '.DS_STORE' files were found.
goto ._.*
if errorlevel 0 echo All '.DS_STORE' files have been deleted.

:._.*
echo.
echo Searching for '._.*' files.
del /s /q /f /a:rash ._.* 2> nul
if errorlevel 1 echo No '._.*' files were found.
goto END
if errorlevel 0 echo All '._.*' files have been deleted.
echo.

:END
echo All tasks have now been finished.
pause

任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

您需要使用resize(strlen(str.c_str()))循环,如下所示循环遍历子文件夹:

%n

您可以对提供的代码进行任何小的更改。

希望这会有所帮助!