#137677 - 2005-04-11 04:08 PM
Delete files by date
|
mrbrown66
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
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
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
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
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 2220 anonymous users online.
|
|
|