joopgoudvis Posted April 8, 2008 Author Posted April 8, 2008 (edited) weaponx said: You use FileMove() to rename files.So you say, that I have to replace the filecopy function with the filemove function? Quote While 1$file = FileFindNextFile($search) If @error Then ExitLoopIf StringInStr($file, "XS-32", 2) <> 0 Then; Search for your example textFileCopy("C:\XS\" & $file, "H:\XS\KVA\" , 9); Move the file. Read the helpfile on this command. 9 = Create dirs and overwrite if exists!!EndIf Edited April 8, 2008 by joopgoudvis
d4rk Posted April 8, 2008 Posted April 8, 2008 FileMove("H:\XS Dir\XS-32dasdada.xml","H:\XS Dir\XS-32.xml",9) hope this can help [quote]Don't expect for a perfect life ... Expect a least troubles ones[/quote]Contact me : ass@kiss.toWhat I Have Done :Favorites Manager Mangage your favorite's folder, that's coolPC Waker For those who want to save stickersWebScipts Supporter For those who've just started with Web and WebScriptsTemporary Looker Simple but powerful to manage your Temporary folder, you know what you downloaded[UDF] _NumberFormat() Better performance on number display[UDF] _DirGet() What a folder contain [how many (hidden,normal,...) files], with one line of code[UDF] _IsPressEs() Just like _IsPress() but for a group of keys
weaponx Posted April 8, 2008 Posted April 8, 2008 No. I said you use FileMove() to rename files. I really don't understand why you are still stuck on this, FileCopy($source, $destination). If the original file is called "ABC" and you need it to be called "XYZ", you do FileCopy("ABC", "XYZ").
joopgoudvis Posted April 8, 2008 Author Posted April 8, 2008 (edited) Wouldn't that give problems? because I don't know the exact filename each time, I used FileFindFirst file, to pick 'XS-32'out of the filename to move the complete file., because the filename is huge. Quote $searchdir = "C:\XS\"; See use below here; Shows the filenames of all files that are found.$search = FileFindFirstFile($searchdir &"*XS-32*" ); Search in the $searchdir directory; Check if the search was successfulIf $search = -1 ThenMsgBox(0, "Error", "No files/directories matched the search pattern")ExitEndIfWhile 1$file = FileFindNextFile($search) If @error Then ExitLoopIf StringInStr($file, "XS-32", 2) <> 0 Then; Search for your example textFileCopy("C:\XS\" & $file, "H:\XS\KVA\" , 9); Move the file. Read the helpfile on this command. 9 = Create dirs and overwrite if exists!!EndIf;MsgBox(4096, "File:", $file); File that is found is displayed hereWEnd; Close the search handleFileClose($search) Edited April 8, 2008 by joopgoudvis
weaponx Posted April 8, 2008 Posted April 8, 2008 Dude. FileFindNextFile() is returning the filename to be copied!
d4rk Posted April 8, 2008 Posted April 8, 2008 why don't you copy file from C:\ To H:\ with the new name , so you don't have to use FileMove() [quote]Don't expect for a perfect life ... Expect a least troubles ones[/quote]Contact me : ass@kiss.toWhat I Have Done :Favorites Manager Mangage your favorite's folder, that's coolPC Waker For those who want to save stickersWebScipts Supporter For those who've just started with Web and WebScriptsTemporary Looker Simple but powerful to manage your Temporary folder, you know what you downloaded[UDF] _NumberFormat() Better performance on number display[UDF] _DirGet() What a folder contain [how many (hidden,normal,...) files], with one line of code[UDF] _IsPressEs() Just like _IsPress() but for a group of keys
joopgoudvis Posted April 8, 2008 Author Posted April 8, 2008 (edited) *Slams his head against the wall* Oh my god! How could I be so STUPID! Thank you very very very much! last question about this subject: I have several dirs where he needs to copy and search too, I could just copy-past the code a few times, but is there a proper way to achief it in code? Example: The logfiles are in one folder XS-1, XS-2,XS-3 XS-1 --> Folder1 on location A: XS-2 --> Folder2 on location B: Etc etc Edited April 8, 2008 by joopgoudvis
weaponx Posted April 8, 2008 Posted April 8, 2008 What I don't understand is why you are using FileFindFirstFile()...FileFindNextFile(). If there are multiple matches won't you be overwriting the same file in the destination??? Why can't this do everything you asked?: $source = "C:\XS" $destination = "H:\XS" FileCopy($source & "\*XS-32*", $destination)
joopgoudvis Posted April 8, 2008 Author Posted April 8, 2008 (edited) Because i'm new too auto it and that command worked...*Shame on me* And I need to copy a file, with a filename that is huge, and each time, the name is different, except for XS-32 in the filename. And there are other files in that dir. Yes, also they need to be copied, but too other folders, and with other filenames. Edited April 8, 2008 by joopgoudvis
d4rk Posted April 8, 2008 Posted April 8, 2008 joopgoudvis said: Because i'm new too auto it and that command worked...*Shame on me*are there any question ? what about the XS-1 and XS-2 and XS-3 ? [quote]Don't expect for a perfect life ... Expect a least troubles ones[/quote]Contact me : ass@kiss.toWhat I Have Done :Favorites Manager Mangage your favorite's folder, that's coolPC Waker For those who want to save stickersWebScipts Supporter For those who've just started with Web and WebScriptsTemporary Looker Simple but powerful to manage your Temporary folder, you know what you downloaded[UDF] _NumberFormat() Better performance on number display[UDF] _DirGet() What a folder contain [how many (hidden,normal,...) files], with one line of code[UDF] _IsPressEs() Just like _IsPress() but for a group of keys
weaponx Posted April 8, 2008 Posted April 8, 2008 joopgoudvis said: Because i'm new too auto it and that command worked...*Shame on me*And I need to copy a file, with a filename that is huge, and each time, the name is different, except for XS-32 in the filename.And there are other files in that dir.Yes, also they need to be copied, but too other folders, and with other filenames.Oh god.FileCopy("C:\XS1\*XS-32*", "H:\XS1")FileCopy("C:\XS2\*XS-32*", "H:\XS2")FileCopy("C:\XS3\*XS-32*", "H:\XS3")-or-For $X = 1 to 3FileCopy("C:\XS" & $X & "\*XS-32*", "H:\XS" & $X)Next
joopgoudvis Posted April 8, 2008 Author Posted April 8, 2008 (edited) I'll try that Thank you Edited April 8, 2008 by joopgoudvis
Triblade Posted April 10, 2008 Posted April 10, 2008 The best way to get help with that is, I think, to post here when what has to move where. All we know now is that there has to be "XS-32" in the filename. These files are all in the same folder. They have to move to a new location. How do we know which location they have to move to? So what rule is defining where a file has to go? My active project(s): A-maze-ing generator (generates a maze) My archived project(s): Pong3 (Multi-pinger)
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