Deleting files older than a specific date or age
I needed to delete a chunk of cookies today – but I didn’t want to delete them all.
Thankfully there is a handy command that is within Windows versions after XP such as Server 2003 and Vista that will enable to clean up without too many problems.
The forfiles command will allow you to set a specific date for a file so that you don’t delete recent cookies:
forfiles /S /p "C:\Users\John\cookies" /D -150 /c "cmd /c del @path"
If you wanted to be super cool and delete multiple user cookie folders you could do something like this:
for /D %D in (C:\Users\*) DO forfiles /S /p "%D\cookies" /D -150 /c "cmd /c del @path"
This will enumerate all of the user folders in the C:\Users folder and then clean up the cookies folders inside.
If you wanted to – you can change the amount of days from 150 days to any other amount you like by changing /D -150 to any other number of days (or even use a specific date).
Related posts:
- Edit files with Notepad++ From Anywhere on your Network Notepad++ is a very handy tool. It rocks. What is...
- Remove Network Printers from Users Before they Log On I had a little trouble with an HP Printer driver...
- Adding Printers will Hang a Vista Logon to a Domain Vista's UAC prevents standard users from installing printer drivers by...
- IIS and those pesky Flash files Doesn’t it drive you mad when you set up an...
- Uninstall Ranger from a Computer without the RangerRemove User Sometimes it might be necessary to remove Sentinel’s Ranger software...
Related posts brought to you by Yet Another Related Posts Plugin.
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.