kurtbullock Posted October 27, 2010 Share Posted October 27, 2010 Hi there, So I'm a newcommer to AutoIT, and it looks amazing! So I've created a few sample scripts while following the instructions in the documentation, but my first production script is having problems. I have a really simple objective: copy folders from a network drive to a folder on the desktop. It's a Toshiba printer/scanner, with a built in network share. I created the following script: FileCopy("\\MFP-052903859\FILE_SHARE\SCAN\*.*", "%homepath%\printer_scans\",9) When I do this, I end up getting a folder named "%homepath%" on my desktop. It's not inserting the homepath into the script. How do I use environmental variables in my scripts? Thanks for your help! Link to comment Share on other sites More sharing options...
Varian Posted October 27, 2010 Share Posted October 27, 2010 Make sure you enable expansion of environment variablesOpt('ExpandEnvStrings', 1) Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted October 27, 2010 Share Posted October 27, 2010 Or use EnvGet() .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
kurtbullock Posted October 28, 2010 Author Share Posted October 28, 2010 Great - that took care of it. Now is there a flag to make it copy any directories found, to the destination? As I have it, it copies all the files in the "From" folder, but not any folders. Thanks! Link to comment Share on other sites More sharing options...
Varian Posted October 28, 2010 Share Posted October 28, 2010 (edited) Robocopy,xcopy...or one of the many file list to array recursive UDFs to find all files recursively and then use filecopy replacing the destination by stringreplace or regular expression Edited October 28, 2010 by Varian Link to comment Share on other sites More sharing options...
JoHanatCent Posted October 28, 2010 Share Posted October 28, 2010 DirCopy() ? Link to comment Share on other sites More sharing options...
GEOSoft Posted October 28, 2010 Share Posted October 28, 2010 That is one of the pitfalls of using wildcards in functions like FileCopy(). By the way "*.*" means nothing to Windows "*" is exactly the same thing. Opt('ExpandEnvStrings', 1) $sPath = "\\MFP-052903859\FILE_SHARE\SCAN\" $sSearch = FileFindFirstFile($sPath & "*") If NOT @Error Then While 1 $sFile = FileFindNextFile($sSearch) If @error Then ExitLoop If @Extended Then DirCopy($sPath & $sFile, "%homepath%\printer_scans\" & $sFile, 1) Else FileCopy($sPath & $sFile, "%homepath%\printer_scans\" & $sFile, 9) EndIf WEnd EndIf George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Zibit Posted October 28, 2010 Share Posted October 28, 2010 you can use the _RunDOS command using xcopy or cp Creator Of Xtreme DevelopersPixel Pattern UDFTray GUI UDFMathssend & recive register scriptMouse Control via Webcam 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