I'm trying to move the files from one directory into another based on their timestamp. If I run this from the source directory and use FileFindFirstFile("*.dss") it works. If I change that to a path, it returns a 1 which seems good but then the $t = FileGetTime($file, 0) line doesn't work. I don't understand what is going on here. I've read a bunch of FileFindFirst File topics but don't see how mine is different.
I want to have the source path in there because a user need to run it and I don't want to run the risk of her moving it out of the directory and suddenly moving all sorts of files from her desktop or wherever into the folders on the server.
$sourcePath = "\\Dictations\Backups\Backup\"
$destinationPath = "\\Dictations\Backups\FolderA\"
$search = FileFindFirstFile($sourcePath & "*.dss") ;;Everything works fine if this is "*.dss"
If $search = -1 Then
MsgBox(0, "Error", "No files/directories matched the search pattern")
Exit
EndIf
While 1
$file = FileFindNextFile($search)
If @error Then ExitLoop
;Get the date of the source file which will be the destination folder name
$t = FileGetTime($file, 0)
If Not @error Then
$yyyymd = $t[0] & $t[1]& $t[2]
Else
MsgBox(0, "Error", "Can't get the date")
EndIf
;See if destination folder exsists, create folder if it doesn't
If FileExists($destinationPath & $yyyymd) Then
Else
;MsgBox(4096,"Creating dir" , "Creating directory \\Dictations\Backups\FolderA\" & $yyyymd)
DirCreate($destinationPath & $yyyymd)
EndIf
; See if the file exists at destination, if not then move it there
If FileExists($destinationPath & $yyyymd & "\" & $file) Then
Else
;MsgBox(4096,"Copying" , "Copying " & $file & " to \FolderA\" & $yyyymd)
FileMove($file, $destinationPath& $yyyymd & "\" & $file)
EndIf
WEnd
; Close the search handle
FileClose($search)