Page 1 of 4 1234>
Topic Options
#33441 - 2002-11-25 08:49 PM Copy Based On FileDate
Austin Offline
Seasoned Scripter

Registered: 2002-01-24
Posts: 439
I did a search on the board but couldnt find what I was looking for but I know this must be a common issue so my searching must just stink.

Anyways what I want to do is move files based on the creation date of the file... I want to use SerialDate() to move files based on date-60 days. I understand the part about performing the math to get $COPYDATEbut I dont understand how to say something to the effect of ....

code:
 COPY *.* (WHERE DATE IS BEFORE $COPYDATE) 

Any help is appreciated..

Thanks
_________________________
Austin Henderson

Top
#33442 - 2002-11-25 08:55 PM Re: Copy Based On FileDate
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Take a look at XCOPY /D under the Command Prompt or take a look at CleanTempFiles() - Cleans up the temporary directories (or any arbitrary directory) if you ned a UDF.
_________________________
There are two types of vessels, submarines and targets.

Top
#33443 - 2002-11-25 09:51 PM Re: Copy Based On FileDate
Austin Offline
Seasoned Scripter

Registered: 2002-01-24
Posts: 439
Yeah I thought of using the xcopy method but cant use that because it copied files after date specified... I want to move files before a certain date.. maybe I am thinking the wrong way but I dont see how the xcopy solution will work.

Thank you
_________________________
Austin Henderson

Top
#33444 - 2002-11-25 09:58 PM Re: Copy Based On FileDate
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
I think you need something like:
http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic;f=12;t=000234
code:
if 60<getfileage($file)
move
endif

how much easier could be?
_________________________
!

download KiXnet

Top
#33445 - 2002-11-25 10:06 PM Re: Copy Based On FileDate
Austin Offline
Seasoned Scripter

Registered: 2002-01-24
Posts: 439
not much... UDF just did not pull in my search because it does not have a very detailed description.

You rock thank you for the help.
_________________________
Austin Henderson

Top
#33446 - 2002-11-25 10:09 PM Re: Copy Based On FileDate
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
austin, currently the udf-collection sites do not have search (just yet) but it's a lot easier to find these (I did check from there)...

try 'em out.
_________________________
!

download KiXnet

Top
#33447 - 2002-11-26 09:28 AM Re: Copy Based On FileDate
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Hmm ... I think Getfileage() has a leap year problem !

maybe it's best to take a combination of intrinsic getfiletime() and one of the Date Calculation udfs !

Jochen
_________________________



Top
#33448 - 2002-11-26 09:44 AM Re: Copy Based On FileDate
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Or even use 3rd Party tools for that task as they will be much faster !!!

(Now, don't cry heresy ! Just try a Dirplus() on c:\ [Big Grin] )
_________________________



Top
#33449 - 2002-11-26 09:45 AM Re: Copy Based On FileDate
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
why not even dirscan()
_________________________
!

download KiXnet

Top
#33450 - 2002-11-26 09:59 AM Re: Copy Based On FileDate
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11625
Loc: CA
Because any KiXtart script will be SLOW compared to most 3rd party utils.

If you're only doing a small directory KiXtart UDFs are fine, but if you're looking at manipulating thousands of files on a 200GB volume, then KiXtart is not the program to be using. This is also assuming you're looking for something either real cheap or preferrably free.

Maybe take a look at some of these for example.

File Manipulation Utilities

More file managers

Even More File Managers

[ 26. November 2002, 10:04: Message edited by: NTDOC ]

Top
#33451 - 2002-11-26 02:46 PM Re: Copy Based On FileDate
Austin Offline
Seasoned Scripter

Registered: 2002-01-24
Posts: 439
Thanks for the help.. I will look into all of these... I am talking about 60 folders that I wish to move with < 4 GB of data.. I think I ill use the kix options but will certainly look into the 3rd party utils.

Thanks again
_________________________
Austin Henderson

Top
#33452 - 2002-11-26 02:52 PM Re: Copy Based On FileDate
Waltz Offline
Seasoned Scripter

Registered: 2002-08-01
Posts: 485
Loc: Waterloo, Ontario, Canada
wild stab...
attrib the archive bit on the files with a 'before' date and then xcopy with /a or /m switch?
_________________________
We all live in a Yellow Subroutine...

Top
#33453 - 2002-11-26 02:54 PM Re: Copy Based On FileDate
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
isn't that faster to just do the job at once?
_________________________
!

download KiXnet

Top
#33454 - 2002-11-26 03:19 PM Re: Copy Based On FileDate
Austin Offline
Seasoned Scripter

Registered: 2002-01-24
Posts: 439
So you are saying use the getfileage() to determine if the file can be archived? then set the bit on those files... then use xcopy to move them?

Am I following you?

Thanks
_________________________
Austin Henderson

Top
#33455 - 2002-11-26 03:25 PM Re: Copy Based On FileDate
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
not sure if waltz wanted to say that but it sure sounded like that.

and, once you think, the disk access amount grows a lot.
that's why it is a lot simpler to just copy the file when right time conditions are met.
_________________________
!

download KiXnet

Top
#33456 - 2002-11-26 04:00 PM Re: Copy Based On FileDate
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
The CleanTempFiles UDF referenced above does what Austin wants, however it delets files above a certain age and does not move them. This would be only a minor change to get the move going.
_________________________
There are two types of vessels, submarines and targets.

Top
#33457 - 2002-11-26 04:14 PM Re: Copy Based On FileDate
Waltz Offline
Seasoned Scripter

Registered: 2002-08-01
Posts: 485
Loc: Waterloo, Ontario, Canada
yah, that was it...not very efficient tho...hence the wild stab caveat...

How about comparing the files against a file with the specified date?

code:
$rc = CompareFileTimes($file_x, $specified_date_file)
IF $rc = -1 ; $file_x is older
; copy $file_x command goes here
ENDIF



[ 26. November 2002, 16:31: Message edited by: Waltz ]
_________________________
We all live in a Yellow Subroutine...

Top
#33458 - 2002-11-26 04:15 PM Re: Copy Based On FileDate
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
waltz, I must still wonder what does that xcopy do there?
if you check on manual you will see kixtart inbuild command: copy [Wink]
_________________________
!

download KiXnet

Top
#33459 - 2002-11-26 04:33 PM Re: Copy Based On FileDate
Waltz Offline
Seasoned Scripter

Registered: 2002-08-01
Posts: 485
Loc: Waterloo, Ontario, Canada
i had my tongue over my eyetooth and i couldn't see what i was saying... [Wink]
_________________________
We all live in a Yellow Subroutine...

Top
#33460 - 2002-11-26 10:11 PM Re: Copy Based On FileDate
Austin Offline
Seasoned Scripter

Registered: 2002-01-24
Posts: 439
I am thinking of using the gerfileage() but I have a problem where I have a directory and I want to enumerate a listing of all the folders in that directory.. then I need to get the age of those folders.. then move them based on that age.. well the only way I can think of doing this is by outputting to a temp file a dir listing then reading from that file for age.. is there a better way?

Thanks
_________________________
Austin Henderson

Top
Page 1 of 4 1234>


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

Who's Online
0 registered and 229 anonymous users online.
Newest Members
BeeEm, min_seow, Audio, Hoschi, Comet
17882 Registered Users

Generated in 0.084 seconds in which 0.038 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