batch remove folder windows
save as file_remove.bat------------------------------------------------------------------------ @echo off
REM Iterate over all folders in the current directory that start with "AA"
for /d %%d in (AA*) do (
rmdir /s /q /verbose "%%d"
)
--------------------------------------------------------------------------
Here's how the script works with the /verbose option:
The
forloop iterates over all directories in the current directory that have names starting with "AA".The
rmdircommand is used to delete each directory and all of its contents, and the/verboseoption is used to show more information about the deletion process.The
/soption is used to delete the directory and all of its subdirectories and files.The
/qoption is used to delete the directory without asking for confirmation.
The /verbose option will display a message for each folder that is being deleted, indicating the name of the folder and the number of files and directories that are being deleted. This can be helpful for troubleshooting and debugging purposes.
To delete all folders in the current directory that start with the letters "AA", "BB", or "AB", you can modify the for command to include multiple patterns. Here's the modified batch file that does this:
--------------------------------------------------------------------------------
@echo off
REM Iterate over all folders in the current directory that start with "AA", "BB", or "AB"
for /d %%d in (AA*,BB*,AB*) do (
REM Delete the folder and all of its contents
rmdir /s /q "%%d"
)
REM Pause for demonstration purposes
pause --------------------------------------------------------------------------------