Page 1 of 1 1
Topic Options
#137677 - 2005-04-11 04:08 PM Delete files by date
mrbrown66 Offline
Lurker

Registered: 2005-04-11
Posts: 2
Hi there,

Could anyone recommend a script that will delete files by date?

I have an FTP subfolder I would like to keep tidy by deleting any files older than 2 weeks.

Thanks,
Jared

Top
#137678 - 2005-04-11 04:25 PM Re: Delete files by date
mima Offline
Hey THIS is FUN

Registered: 2002-01-25
Posts: 217
Loc: Jönköping, Sweden
Hi mrbrown66
take a look at this post
Remove files by date

My example is working fine.

/Mima

Top
#137679 - 2005-04-11 04:57 PM Re: Delete files by date
mrbrown66 Offline
Lurker

Registered: 2005-04-11
Posts: 2
Works well, But I need a script that will also check subdirectories as well.

Howerever, I only want it to delete the old files of a certain age, not the folders that contain the older files.

Any recommendations?

Top
#137680 - 2005-04-11 05:38 PM Re: Delete files by date
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
Quote:

Works well, But I need a script that will also check subdirectories as well.

Howerever, I only want it to delete the old files of a certain age, not the folders that contain the older files.

Any recommendations?




i think my example script that i posted in the above thread will do what you are after, with just a slight modification of adding a '/s' option to the DIRPlus UDF.

it uses the following UDF's

DirPlus, TimeConvert, and FlipCTime

Code:

Call 'g:\kix\udf\dirplus\dirplus.kix'
Call 'g:\kix\udf\TimeConvert\TimeConvert.kix'
Call 'g:\kix\udf\FlipcTime\flipcTime.kix'

$files = Dirplus('\\flag-fs01\sys\deltemp','/s /a-d')
$3days = 259200
$14days = 1209600

For Each $file In $files
$ts = Split($file.DateLastModified)
$ts[0] = Split($ts[0],"/")
$ts[0] = $ts[0][2] + '/' + $ts[0][0] + '/' + $ts[0][1]
$ts[1] = timeconvert($ts[1]+" "+$ts[2])


;check to see if the file is older than 14 days vs the current date and time.
If flipctime(@DATE,@TIME) - flipctime($ts[0],$ts[1]) >= $14days
? "Delete! " $file.name " " $ts[0]

; --this needs to be commented out--
;$file.delete
EndIf
Next



Bryce

Top
#137681 - 2005-04-17 12:17 AM Re: Delete files by date
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Or use the CleanDirectory() UDF.
_________________________
There are two types of vessels, submarines and targets.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.132 seconds in which 0.072 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org