Create .bat to recursively delete subfolders
I am working to migrate from Drivebender to Drivepool. If not familiar, these are duplication softwares, but function differently. Drivebender has primary and secondary files, and Drivepool does not.
Anyways, I am attempting to clean up the folders left behind after migration. Drivebender creates folders named "FOLDER.DUPLICATE.$DRIVEBENDER". I am trying to create a .bat script that will remove all of these folders. I keep getting "Access is Denied" when attempting to run what I have below. Any suggestions?
@echo off
for /r %%f in (FOLDER.DUPLICATE.$DRIVEBENDER) do if exist %%f (
echo %%f
rd "%%f"
)
@echo off
for /r %%f in (FOLDER.DUPLICATE.$DRIVEBENDER) do if exist "%%f" echo rd /s /q "%%f"
:: PLEASE NOTE THE ECHO BEFORE THE RD COMMAND.
:: DELETE IT ONCE YOU ARE SURE IT IS DOING WHAT YOU WANT.
This works for me. If I was having problems taking those folders after knowing the above script works, I would use the takeown
utility and or the CACLS
utulity that comes with windows and would be careful to only touch the permissions on those folders.