Sign in to follow this  
Followers 0
kurtbullock

FileCopy Issues

8 posts in this topic

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!

Share this post


Link to post
Share on other sites



Make sure you enable expansion of environment variables

Opt('ExpandEnvStrings', 1)

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites

#5 ·  Posted (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 by Varian

Share this post


Link to post
Share on other sites

DirCopy() ?


Share this post


Link to post
Share on other sites

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!"

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0