Jump to content

Recommended Posts

Posted

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!

Posted

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!

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
Posted

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

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...