Automating File/Folder Deletion


As promised in my last post, here is a sample batch file for automating deletion of files or folders.

For a tutorial on setting up a task in Windows Task Scheduler – please see the following previous post:

Assuming you have set up your temporary file structure as suggested in my last post, save the following code in a .BAT file and set up an automated task to run it as a program on a scheduled.


REM CD C:\TMP\
RMDIR /S /Q C:\TMP\

REM CD C:\TEMP\
RMDIR /S /Q C:\TEMP\

REM CD "C:\Users\USERNAME\AppData\Roaming\Macromedia\Flash Player\macromedia.com\support\flashplayer\sys\"
RMDIR /S /Q "C:\Users\USERNAME\AppData\Roaming\Macromedia\Flash Player\macromedia.com\support\flashplayer\sys\"

REM CD "C:\Users\USERNAME\AppData\Roaming\Macromedia\Flash Player\#SharedObjects\"
RMDIR /S /Q "C:\Users\USERNAME\AppData\Roaming\Macromedia\Flash Player\#SharedObjects\"

PAUSE

You will need to update the code with your username in the 4 places that say “USERNAME”.

This code will delete all files in the C:\TEMP & C:\TMP folders as well as cleanup after Macromedia’s Flash Player which I find tends to leave quite a few temporary folders and files behind.

When the code runs, it will pause at the end for you to review its progress until you press any button.

Happy New Years!