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