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?
solution that worked for me was
create bat file "delete_all_desktop_ini.bat" with
del /s /q /f /a ".\desktop.ini"
put it in a folder and run it
it will delete all desktop inis in current directory and sub directories of this file.
i put it in a project folder that is in google drive
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With