#33481 - 2002-12-01 01:25 PM
Re: Copy Based On FileDate
|
Austin
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
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?
|
Top
|
|
|
|
#33483 - 2002-12-02 03:18 AM
Re: Copy Based On FileDate
|
Austin
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
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
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
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
|
|
|
|
#33488 - 2002-12-05 06:27 AM
Re: Copy Based On FileDate
|
Austin
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
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
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
Seasoned Scripter
Registered: 2002-01-24
Posts: 439
|
$Date is also correct...??
_________________________
Austin Henderson
|
Top
|
|
|
|
#33494 - 2002-12-05 06:49 AM
Re: Copy Based On FileDate
|
Austin
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
|
|
|
|
#33497 - 2002-12-05 05:29 PM
Re: Copy Based On FileDate
|
Austin
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
|
|
|
|
#33500 - 2002-12-05 09:59 PM
Re: Copy Based On FileDate
|
Austin
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
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 194 anonymous users online.
|
|
|