Page 3 of 4 <1234>
Topic Options
#33481 - 2002-12-01 01:25 PM Re: Copy Based On FileDate
Austin Offline
Seasoned Scripter

Registered: 2002-01-24
Posts: 439
The files are 100 MB plus each. It will be going across the network... I just thought it would be better to do it that way and then use xcopy to move them.. am I thinking wrong? Reason I say that is XCOPy will only let me copy files modified after certain date... not before a date or in a range..
_________________________
Austin Henderson

Top
#33482 - 2002-12-01 02:28 PM Re: Copy Based On FileDate
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
How many of these files do you have to move? Would it pay to compress them first and then move them?
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#33483 - 2002-12-02 03:18 AM Re: Copy Based On FileDate
Austin Offline
Seasoned Scripter

Registered: 2002-01-24
Posts: 439
It will run once a week and copy about 7 files when it runs.. but it will have to check the dates on about 67 or so of the files.. not a lot I know just trying to be efficient.

Compressing will not help they are PST files that have not been modified only created.

Thanks for the dialog.
_________________________
Austin Henderson

Top
#33484 - 2002-12-03 08:30 PM Re: Copy Based On FileDate
Austin Offline
Seasoned Scripter

Registered: 2002-01-24
Posts: 439
Having a problem passing a variable into the call.. the $FullPath is displaying correctly but is not working on the GetFolder call... help.

code:
   	$fso = CreateObject("Scripting.FileSystemObject")
$FullPath="$DestDir\$FileName"
?"FullPath: "$FullPath
$f = $fso.GetFolder($FullPath)
?"Folder "$f

_________________________
Austin Henderson

Top
#33485 - 2002-12-03 08:42 PM Re: Copy Based On FileDate
Austin Offline
Seasoned Scripter

Registered: 2002-01-24
Posts: 439
Forgive me I am dumb... had to get some water and come back.. just put wrong variables in.

Thanks
_________________________
Austin Henderson

Top
#33486 - 2002-12-05 06:22 AM Re: Copy Based On FileDate
Austin Offline
Seasoned Scripter

Registered: 2002-01-24
Posts: 439
well here is what I have thus far... but still not working... works but the date compare portion does not. What am I doing wrong on calculating if $DirAge <= $Age?

Thanks

code:
 ;FUNCTION      MoveAge()
;
;AUTHOR Austin Henderson (KAHenderson@FirstFleetInc.com)
;
;VERSION 1.0
;
;ACTION Moves/Deletes Directories Based On Dir Creation Date
;
;PARAMETERS ACTION
; 1 - Move Files
; 2 - Delete Files
;
; DIR
; Directory From Which Files Will Be Moved/Deleted
;
; optional DestDir
; Directory To Which Files Will Be Moved
;
; AGE
; Max age of files to move
;
; optional LogFile
; File to write logging information to
;
;REMARKS
;
;DEPENDENCIES datemath.udf
; serialdate.udf
;
;KIXTART VER 4.10+
;
FUNCTION MoveAge($Action, $Dir, optional $DestDir, $Age, optional $Log)

if exist ("$DestDir") = 0
MD "$DestDir"
if @error <> 0
goto err
endif
endif

$FolderName = Dir("$Dir")
While $FolderName <> "" and @ERROR = 0
if $FolderName = "." or $FolderName = ".."
goto skp
endif
$fso = CreateObject("Scripting.FileSystemObject")
$f = $fso.GetFolder("$Dir\$FolderName")
$DateARRAY=Split($f.DateCreated," ",1)
$Date=$DateArray[0]
$SplitARRAY=Split("$Date","/",3)
$DateYEAR=$SplitARRAY[2]
$DateMONTH=$SplitARRAY[0]
$DateDAY=$SplitARRAY[1]
$DirDate=$DateYEAR+"/"+$DateMONTH+"/"+$DateDay
$DirAge=DateMath("$DirDate","@DATE")
if $DirAge >= $Age
$Silent=RedirectOutput($Log,0)
?"[@TIME] FOLDER: $FolderName IS $DirAge DAYS OLD AND WILL BE MOVED"
if exist ("$DestDir\$FolderName") = 0
?"[@TIME] FOLDER $FolderName DOES NOT EXIST - CREATING"
MD "$DestDir\$FolderName"
if @error <> 0
?"[@TIME] ERROR CREATING $FolderName - QUITTING"
goto err
endif
endif
?"[@TIME] COPYING FOLDER $FolderName TO ARCHIVE"
COPY "$Dir\$FolderName\*.*" "$DestDir\$FolderName\*.*"
if $Action = 2
;$Silent=RedirectOutput($Log,0)
?"[@TIME] DELETING CONTENTS OF FOLDER - "$FolderName
DEL "$Dir\$FolderName\*.*"
?"[@TIME] DELETING FOLDER - "$FolderName
RD "$Dir\$FolderName"

endif
endif
:skp
$FolderName = Dir() ; retrieve next file
Loop

:err
$Silent=RedirectOutput("",0)
ENDFUNCTION

_________________________
Austin Henderson

Top
#33487 - 2002-12-05 06:27 AM Re: Copy Based On FileDate
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
so, what part is not working?
does it populate the vars?

what are the dates it populates and counts wrong?

as example, do a line:
"if $DirAge >= $Age"

before:
if $DirAge >= $Age

to see what it actually compares.
_________________________
!

download KiXnet

Top
#33488 - 2002-12-05 06:27 AM Re: Copy Based On FileDate
Austin Offline
Seasoned Scripter

Registered: 2002-01-24
Posts: 439
The $DirAge is reading as 730854 for files that have been created today.
_________________________
Austin Henderson

Top
#33489 - 2002-12-05 06:28 AM Re: Copy Based On FileDate
Austin Offline
Seasoned Scripter

Registered: 2002-01-24
Posts: 439
$Age is right
_________________________
Austin Henderson

Top
#33490 - 2002-12-05 06:30 AM Re: Copy Based On FileDate
Austin Offline
Seasoned Scripter

Registered: 2002-01-24
Posts: 439
Is running on NT 4.0 IE 6.0 box... developed on XP Pro box...
_________________________
Austin Henderson

Top
#33491 - 2002-12-05 06:41 AM Re: Copy Based On FileDate
Austin Offline
Seasoned Scripter

Registered: 2002-01-24
Posts: 439
$Date is also correct...??
_________________________
Austin Henderson

Top
#33492 - 2002-12-05 06:43 AM Re: Copy Based On FileDate
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
what is datemath() ?
_________________________
!

download KiXnet

Top
#33493 - 2002-12-05 06:47 AM Re: Copy Based On FileDate
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
ok, found on scriptlogics site.
have you posted a complain about that?

anyway, try it with the datecalc() which has no dependencies.

{edit}
btw, the datecalc also counts it for you.

[ 05. December 2002, 10:01: Message edited by: Lonkero ]
_________________________
!

download KiXnet

Top
#33494 - 2002-12-05 06:49 AM Re: Copy Based On FileDate
Austin Offline
Seasoned Scripter

Registered: 2002-01-24
Posts: 439
nope... no complaint yet.. wanted to make sure I wansnt screwing it up.

Will try in the morning.

THanks
_________________________
Austin Henderson

Top
#33495 - 2002-12-05 06:51 AM Re: Copy Based On FileDate
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
austin, if it really is returning such a weird number, then there is not all correct.

and as it has so many dependencies may way of working would:
-try other udf
-vote the datemath() on www.kixlib.com as I feel (not well for sure)
_________________________
!

download KiXnet

Top
#33496 - 2002-12-05 09:48 AM Re: Copy Based On FileDate
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
DateCalc() was written entirely without dependencies (ok, Kix 4.x) ... I prefer having independant UDFs

It SHOULD return the correct difference and or Date if used correctly

hth
Jochen
_________________________



Top
#33497 - 2002-12-05 05:29 PM Re: Copy Based On FileDate
Austin Offline
Seasoned Scripter

Registered: 2002-01-24
Posts: 439
I have found the problem.. on NT 4.0 the portion
code:
   	$fso = CreateObject("Scripting.FileSystemObject")
$f = $fso.GetFolder("C:\WINNT")
$DateARRAY=Split($f.DateCreated," ",1)

Is returning a two digit year where on 2K Xp it is returning a four digit year... I will work around this.

Thanks
_________________________
Austin Henderson

Top
#33498 - 2002-12-05 09:04 PM Re: Copy Based On FileDate
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
[Eek!]
_________________________



Top
#33499 - 2002-12-05 09:49 PM Re: Copy Based On FileDate
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
j, can you verify this not to be a problem with datecalc() ?

[ 05. December 2002, 21:50: Message edited by: Lonkero ]
_________________________
!

download KiXnet

Top
#33500 - 2002-12-05 09:59 PM Re: Copy Based On FileDate
Austin Offline
Seasoned Scripter

Registered: 2002-01-24
Posts: 439
It is not a problem with DateCalc() but you can feel free to try it if you wish. I was passing the wrong information into DateCalc() that is why I was getting the odd result...

Example of what I was doing..

$Days=DateCalc("02/12/04","2002/12/04")

The second date was using @DATE and that is the correct format. The first date was determined by the code you can see above.

Thanks
_________________________
Austin Henderson

Top
Page 3 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 194 anonymous users online.
Newest Members
BeeEm, min_seow, Audio, Hoschi, Comet
17882 Registered Users

Generated in 0.149 seconds in which 0.117 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