tasemu Posted July 13, 2009 Share 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] Link to comment Share on other sites More sharing options...
water Posted July 13, 2009 Share 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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Vinu Posted July 13, 2009 Share 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 Link to comment Share on other sites More sharing options...
tasemu Posted July 13, 2009 Author Share 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] Link to comment Share on other sites More sharing options...
Vinu Posted July 13, 2009 Share 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. Link to comment Share on other sites More sharing options...
water Posted July 13, 2009 Share 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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
archgriffin Posted July 13, 2009 Share 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. 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