tasemu Posted July 13, 2009 Posted July 13, 2009 hey i wanna use FileCopy in my script, but my source is in a folder that has a different name for each computer. is there any methods i could use to open that folder. it is also the only folder in there, so maybe somehow i can just make it choose the first folder it finds in that directory or something? any help would be much appreciated. thanks mate [IMG]http://i432.photobucket.com/albums/qq50/tasemu/tasemu_sig.jpg[/IMG]
water Posted July 13, 2009 Posted July 13, 2009 I would have a look in the help file for FileFindFirstFile / FileFindNextFile / FileClose to get the first file. For every file I find I would use FileGetAttrib to check if it's a directory. If yes then start copying. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Vinu Posted July 13, 2009 Posted July 13, 2009 hey i wanna use FileCopy in my script, but my source is in a folder that has a different name for each computer. is there any methods i could use to open that folder. it is also the only folder in there, so maybe somehow i can just make it choose the first folder it finds in that directory or something?any help would be much appreciated.thanks mateMaybe this will help ?(Findfirstfile()/FindNextfile() functions can do this for you) http://www.autoitscript.com/forum/index.php?showtopic=90545&start=0&p=651141&hl=findfirst%20file&fromsearch=1&#entry651141
tasemu Posted July 13, 2009 Author Posted July 13, 2009 cool, thanks alot. but i need to find the first directory, i got the file name [IMG]http://i432.photobucket.com/albums/qq50/tasemu/tasemu_sig.jpg[/IMG]
Vinu Posted July 13, 2009 Posted July 13, 2009 cool, thanks alot. but i need to find the first directory, i got the file name Oh yes it does return directories when you use *.*You have to use FileGetAttrib() function on the returned name of FindNextFile to check if its FileGetAttrib() return has "D" in it. You can see details of these functions in AutoIT help.
water Posted July 13, 2009 Posted July 13, 2009 This should return the first directory in the Start Directory:; Shows the filenames of all files in the current directory. $StartDir = "C:\" $search = FileFindFirstFile($StartDir & "*.*") ; Check if the search was successful If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf While 1 ; Find next file in directory $file = FileFindNextFile($search) If @error Then ExitLoop If StringInStr(FileGetAttrib($StartDir & "\" & $file),"D") > 0 Then MsgBox(4096, "First Directory is: ", $file) ExitLoop EndIf WEnd FileClose($search) My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
archgriffin Posted July 13, 2009 Posted July 13, 2009 Well if it didn't have to be entirely automatic you could do FileOpenDialog or FileSelectFolder. Probably not what you are looking for but thought they should be referenced just in case. "Human kind cannot gain anything without first giving something in return, to obtain; something of equal value must be lost."The Help File is truly your friend.
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