Burgs Posted May 26, 2008 Share Posted May 26, 2008 Hi, I'm having some difficulty copying/moving a file, here is the code I'm using: ; Shows the filenames of all files in the current directory. $search = FileFindFirstFile("C:\SegFiles\BACKS\*.txt") ;copy the file to another directory, overwrite if a file is there already with the same name FileCopy("C:\SegFiles\BACKS\" & $search, "C:\My Documents\17Closes.inp", 9) The file is not being copied in the new Directory, the script compiles fine, can somebody point out the error here? Thank you in advance. Link to comment Share on other sites More sharing options...
Developers Jos Posted May 26, 2008 Developers Share Posted May 26, 2008 (edited) Have a look at the helpfile for the example. FileFindFirst will:Return ValueSuccess: Returns a search "handle" for use with subsequent FileFindNextFile functionsNot a filename. Edited May 26, 2008 by Jos 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...
Burgs Posted May 26, 2008 Author Share Posted May 26, 2008 Thanks for the info, based upon that, I thought I could pass that handle to another variable and use it that way, but I see no difference in the behaviour. So I'm now doing this: ; Shows the filenames of all files in the current directory. $search = FileFindFirstFile("C:\SegFiles\BACKS\*.txt") $use = $search ;copy the file to another directory, overwrite if a file is there already with the same name FileCopy("C:\SegFiles\BACKS\" & $use, "C:\My Documents\17Closes.inp", 9) Link to comment Share on other sites More sharing options...
Developers Jos Posted May 26, 2008 Developers Share Posted May 26, 2008 Now did you look at the example in the Helpfile which is at the bottom of the page explaining FileFindFirst? You need the FileFindNExt() statement. 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...
Burgs Posted May 26, 2008 Author Share Posted May 26, 2008 I'm sorry I'm new to this app. so I'm not following you. I have the statement later in my code as such: ; Shows the filenames of all files in the current directory. $search = FileFindFirstFile("C:\SegFiles\BACKS\*.txt") $use = $search ;copy the file to another directory, overwrite if a file is there already with the same name FileCopy("C:\SegFiles\BACKS\" & $use, "C:\My Documents\17Closes.inp", 9) ...stuff ;go to next file in Directory to repeat process $file = FileFindNextFile($search) Forgive me but I don't understand what you're driving at...what does the FileFindNextFile statement have to do with appending the correct handle to the Copy command? Link to comment Share on other sites More sharing options...
Developers Jos Posted May 26, 2008 Developers Share Posted May 26, 2008 I don't mind helping but you have ignored my question now for the second time. Have you looked at the helpfile example ? It explains how the function should be used. 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...
Burgs Posted May 26, 2008 Author Share Posted May 26, 2008 I have not ignored it, I have looked at it several times, and in fact basically have it cut and pasted into my code. It does not explain to me the logic of the process. The way I'm reading it is that the FileFindFirstFile finds the "first" file in the Directory and assigns it a handle called "$search". I then want to do several things to process this first file (including copying and moving it)...the FileFindNextFile($search) then takes the "next" file (and all remaining others) in the Directory and assigns the handle "$file" to them...if the FileFindNextFile($search) is called after the copy/move how am I to get that first file processed as I wish? Link to comment Share on other sites More sharing options...
Developers Jos Posted May 26, 2008 Developers Share Posted May 26, 2008 (edited) Ok Understrand your confusion. FileFindFirst(0 returns a handle for the Search nothing more. The first time FileFileNext() is ran, the first file is returned that matches the search argument as defined in FileFindFirst(). So you always require the execution of at least one time FileFileNext() to get the first matching file. Edited May 26, 2008 by Jos 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...
Burgs Posted May 26, 2008 Author Share Posted May 26, 2008 OK I guess that makes sense, but it makes me wonder why there is any need to have 2 seperate command statements...confusing. However that is another (unimportant) issue. Thanks again. 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