I want to find and delete every desktop.ini and Recycle Bin.BIN file on a network drive, H:, using a windows batch file. I currently have this:
@echo About to delete all desktop.ini and Recycle Bin.BIN files from H:, press Ctrl+C to cancel or Enter to continue.
@pause
@H:
@for /f "usebackq" %%i in (`dir /s /b /x /A:H ^| find "desktop.ini"`) do del /A:H "%%i"
@for /f "usebackq" %%i in (`dir /s /b /x /A:RH ^| find "Recycle Bin.BIN"`) do del /A:RH "%%i"
@echo Deleting complete, press any key to exit.
@pause
Which works but for any file in a sub-folder with a space in the name it fails with a "cannot find file" error. Any suggestions how to fix that?
del /s /q /f /a desktop.ini
is the current folder. – Watch