Page 1 of 1 1
Topic Options
#185266 - 2008-02-11 11:11 PM How do I copy files older than a certain date?
g_chilcote Offline
Just in Town

Registered: 2008-02-11
Posts: 4
Simple task, I believe. Xcopy with the /D switch can be used to copy files AFTER a certain date. I need to MOVE files BEFORE a certain date. Any help is appreciated.

TIA
Gary

Top
#185270 - 2008-02-11 11:59 PM Re: How do I copy files older than a certain date? [Re: g_chilcote]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
I presume DirPlus() - a recursive dir tool can help. The UDF returns a FileSystem object. I presume it will be possible to verify the ".Date" of every file.
Top
#185272 - 2008-02-12 12:37 AM Re: How do I copy files older than a certain date? [Re: Witto]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
If you combine the fso.Date string with TimeDiff() UDF it will be very easy to accomplish. TimeDiff works by changing date strings to cTime values for the comparison, resulting in a high degree of accuracy.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#185273 - 2008-02-12 12:49 AM Re: How do I copy files older than a certain date? [Re: Glenn Barnas]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
And there is always the built in GETFILETIME() function.
_________________________
Today is the tomorrow you worried about yesterday.

Top
#185276 - 2008-02-12 01:05 AM Re: How do I copy files older than a certain date? [Re: Gargoyle]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
and there is RoboCopy - see, many ways to skin a cat (so to speak)
Top
#185277 - 2008-02-12 01:11 AM Re: How do I copy files older than a certain date? [Re: Gargoyle]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
Only thing with the GetFileTime is that it does a string comparison, not a numerical comparison - you can tell EQUAL, but less than/greater than become more difficult.

(or were you referring simply to getting the file's time?)

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#185278 - 2008-02-12 01:54 AM Re: How do I copy files older than a certain date? [Re: Glenn Barnas]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Just trying to get you going... \:D

I tend to use SerialDate(Left(GetFileTime(filename.txt),1,10)) and make comparisons that way.

Most of mine are If older than 90 days delete. Serial date is really good for that simple calculation.
_________________________
Today is the tomorrow you worried about yesterday.

Top
#185280 - 2008-02-12 04:02 AM Re: How do I copy files older than a certain date? [Re: Gargoyle]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
OK - I use
 Code:
If TimeDiff(GetFileTime($File1), GetFileTime('file2'), 'd') > 1
  Delete $File1
EndIf

This will return a value showing the difference (in days) between the two files. If the value is 1 or more, file1 is older than file2 and can be deleted/copied/whatever.
 Code:
If TimeDiff(GetFileTime($File1), 'Today' 'd') > 90
  Delete $File1
EndIf

to delete files older than 90 days from today.

TimeDiff supports a MS flag, providing values between two dates with millisecond accuracy.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#185289 - 2008-02-12 05:44 PM Re: How do I copy files older than a certain date? [Re: Glenn Barnas]
g_chilcote Offline
Just in Town

Registered: 2008-02-11
Posts: 4
Thanks for the help. I will test some of these methods.

Gary

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.066 seconds in which 0.031 seconds were spent on a total of 13 queries. Zlib compression enabled.

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