Saturday, January 27, 2018

windows 7 - How can I automatically keep folders clean?



I've just wiped my laptop and am starting to move files back on to it now. How can I keep certain folders clean automatically? For example, is there an easy way to automatically deletes all of the contents in a folder older than 2 weeks, and have this process run daily? That would really help in keeping things like my downloads folder from filling with junk.



This is on Windows 7 64-bit.


Answer



You create batch script that deletes content of download folder. And then create windows version of cron and run it on designated intervals.




Batch to delete contents of my folder.



FOR /D %%i IN ("D:\myfolder\*") DO RD /S /Q "%%i" DEL /Q "D:\myfolder\*.*"


Delete folders older than N



forfiles -p "C:\what\ever" -s -m *.* -d  -c "cmd /c del @path"



Forfiles documentation: http://ss64.com/nt/forfiles.html



And cron for windows:
http://support.microsoft.com/kb/308569


No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...