FrozenTeeth Posted February 26, 2010 Share Posted February 26, 2010 The below code moves reports to and archive directory. It also logs the move. The issue I have is the @error returns a zero as in my log file it say's failed to move report. Even thou when I look the file(s) has moved just fine! ; ;move reports for archive ; Dim $filestomove $filestomove = _FileListToArray($ReportsDirectory, "ilb*.rpa") For $x = 1 To $filestomove[0] FileMove($ReportsDirectory & $filestomove[$x], $ReportsBackupDirectory, 1) If @error = 0 Then LogAction("Failed to move report: " & $ReportsDirectory & $filestomove[$x] & " to " & $ReportsBackupDirectory & $filestomove[$x] & " file already exists") Else LogAction("Moved report: " & $ReportsDirectory & $filestomove[$x] & " to " & $ReportsBackupDirectory & $filestomove[$x]) EndIf Next From the help file: FileMove Moves one or more files FileMove ( "source", "dest" [, flag] ) Parameters source The source path and filename of the file to move. (* wildcards are supported) dest The destination path and filename of the moved file. (* wildcards are supported) flag [optional] this flag determines whether to overwrite files if they already exist: Can be a combination of the following: 0 = (default) do not overwrite existing files 1 = overwrite existing files 8 = Create destination directory structure if it doesn't exist (See Remarks). Return Value Success: Returns 1. Link to comment Share on other sites More sharing options...
MvGulik Posted February 26, 2010 Share Posted February 26, 2010 (edited) whatever Edited February 7, 2011 by MvGulik "Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions.""The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014) "Believing what you know ain't so" ... Knock Knock ... Link to comment Share on other sites More sharing options...
FrozenTeeth Posted February 26, 2010 Author Share Posted February 26, 2010 Posible empty entry in you $filestomove array.(?)It moves 6 files a day so I would think that $filestomove array is correct and working the way it should. Link to comment Share on other sites More sharing options...
Negative1 Posted February 26, 2010 Share Posted February 26, 2010 Return Value @Error: 1 = Path not found or invalid 2 = Invalid $sFilter 3 = Invalid $iFlag 4 = No File(s) Found ^^ from help file. If @error = 0 Then LogAction("Failed to move report: " & $ReportsDirectory & $filestomove[$x] & " to " & $ReportsBackupDirectory & $filestomove[$x] & " file already exists") Else LogAction("Moved report: " & $ReportsDirectory & $filestomove[$x] & " to " & $ReportsBackupDirectory & $filestomove[$x]) EndIf this part of the code says if @error = 0 Eg: NO ERROR log action error... looks like you need to put if @error <> 0 then hope that solves it -1 What are we going to do tonight Brain?Same thing we do every night Pinky try to automate the world. Link to comment Share on other sites More sharing options...
Developers Jos Posted February 26, 2010 Developers Share Posted February 26, 2010 Maybe something like this: If FileMove($ReportsDirectory & $filestomove[$x], $ReportsBackupDirectory, 1) Then LogAction("Moved report: " & $ReportsDirectory & $filestomove[$x] & " to " & $ReportsBackupDirectory & $filestomove[$x]) Else LogAction("Failed to move report: " & $ReportsDirectory & $filestomove[$x] & " to " & $ReportsBackupDirectory & $filestomove[$x] & " file already exists. Error" & @error) EndIf SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now