On 29 Jul 2011 at 10:07, John Hornbuckle wrote: > We use folder redirection for users´ "My Documents" and related > folders. Works great, but using this method also causes the Recycle Bin to > be stored on the network-and it can grow quite large. > > I´m looking for an automated way (a script is fine) to delete items from > the Recycle Bin. I´ve found scripts for emptying the Recycle Bin on > logon or logoff, but I don´t want to go that route. Rather, I only want > to delete items from the Recycle Bin that have been there for more than a > specified period of time (probably seven days). > > Anyone know how?
Here's my "EmptyRecycleBin" batch file. You could modify it to use the freeware program TDEL*, which allows you do delete by age. Instead of using RD, use TDEL with the "/S: recurse into subdirectories" command-line switch. ============= Included Stuff Follows ============= @echo BEFORE >%temp%\before.txt dir c:\ | find/i "bytes free">>%temp%\before.txt dir D:\ | find/i "bytes free">>%temp%\before.txt ATTRIB C:\RECYCLER\* -R -S -H /S /D DEL C:\RECYCLER\* /F /S /Q FOR /D %%a in (C:\RECYCLER\*) do RD %%a /S /Q ATTRIB D:\RECYCLER\* -R -S -H /S /D DEL D:\RECYCLER\* /F /S /Q FOR /D %%a in (D:\RECYCLER\*) do RD %%a /S /Q @type %temp%\before.txt @del %temp%\before.txt @echo AFTER @dir c:\ | find/i "bytes free" @dir D:\ | find/i "bytes free" @pause ============= Included Stuff Ends ============= TDEL /? gives you screens and screens of options. HTH * http://www.utopiatemple.com/tutils/tdel.htm -- Angus Scott-Fleming GeoApps, Tucson, Arizona 1-520-290-5038 Security Blog: http://geoapps.com/ ~ Finally, powerful endpoint security that ISN'T a resource hog! ~ ~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~ --- To manage subscriptions click here: http://lyris.sunbelt-software.com/read/my_forums/ or send an email to [email protected] with the body: unsubscribe ntsysadmin
