Purge TMP files that are older than X days

Example scripts and tips (replaces Old Scripts & Tips archive)

Moderators: Dorian (MJT support), JRL, Phil Pendlebury

Post Reply
User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Purge TMP files that are older than X days

Post by Marcus Tettmar » Fri Aug 18, 2000 11:00 pm

Contributed By: Marcus Tettmar [email protected]
Submitted On: 19/08/00

Let>tempdir=c:\ emp
Let>xdays=7
IfFileExists>c:\ emplist.txt,deltemplist
Goto>continue
Label>deltemplist
DeleteFile>c:\ emplist.txt
Label>continue
IfFileExists>c:\ emplogfile.txt,dellogfile
Goto>continue2
Label>dellogfile
DeleteFile>c:\ emplogfile.txt
Label>continue2
Let>RP_WINDOWMODE=2
//remove /s if you don't want subdirectories
Run>command.com /c dir /b /s /a-d %tempdir% >> c:\ emplist.txt
//if using NT change next 2 lines to command.com*
WaitWindowOpen>MS-DOS Prompt
WaitWindowClosed>MS-DOS Prompt
Let>k=1
Label>readfile
ReadLn>c:\ emplist.txt,k,filename
FileDate>filename,fdate
If>filename=##EOF##,doneread
IfFileChanged>filename,>%xdays%,delfile
Goto>donedelfile
Label>delfile
WriteLn>c:\ emplogfile.txt,res,%fdate%:%filename%
DeleteFile>filename
Label>donedelfile
Let>k=k+1
Goto>readfile
Label>doneread
Let>RP_WINDOWMODE=1
Run>notepad.exe c:\ emplogfile.txt

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts