Jump to content

Copy Verification


Recommended Posts

I have a AutoIt script that I wrote for some administrative tasks we complete. Part of that is to copy certain set of code files over that gets applied to the application and if some of the files dont get applied then we get odd issues.

I believe the copy i am having an issue with is a full folder (*.*) vs specific files. In PowerShell I would be able to use get-childitem to virtually index each file and treat each file individually. But not sure how to do that in AI. I have copied the copy funtion and call line from my script.

Keep in mind this is only a small section of the script, the entire file is 1569 lines long.

#include <file.au3>

Func _Copy($copyfile, $copydest)
      
If $copyfile = "" Then
     Msgbox(0, "Copy File - ERROR", "File to copy has not been specified. Script will now exit.")
     Exit
EndIf

$copytest = FileCopy($copyfile, $copydest, 1)

If $copytest = 1 Then ;Means it was successful
     ;Had some Logging code here
EndIf
   
If $copytest = 0 Then ;Means it has not copied
     MsgBox (16, "##### ERROR - File Copy", "File did not copy." & @CRLF & "This window will close in 3 seconds.", 3)
 
     _Copy($copyfile, $copydest)
EndIf

EndFunc



$parmdest = "C:\folder\sub"
_Copy("\\x.x.x.x\config\parms\1st Download\US\*.*", $parmdest)

Thanks in advance

MidwayMonster

Keith Hugginswww.LivingViLife.com | [email="Keith.Visalus@gmail.com"]Keith.Visalus@gmail.com[/email]Want to automate your weightloss and fitness? I lost 20 pounds and 5 inches across my belly in 8 weeks without exercise!Check out my website or shoot me a email for more information

Link to comment
Share on other sites

that should work. I would like to use same function if possible vs creating a new one for directory copies.

I guess i could add in some logic where:

If (stringinstr($copyfile, "*.*", 2)) > 0 then

DirCopy ...

If @error etc

Else

Filecopy ...

Keith Hugginswww.LivingViLife.com | [email="Keith.Visalus@gmail.com"]Keith.Visalus@gmail.com[/email]Want to automate your weightloss and fitness? I lost 20 pounds and 5 inches across my belly in 8 weeks without exercise!Check out my website or shoot me a email for more information

Link to comment
Share on other sites

Thanks for the responses.

Is there a known issue with filecopy? I only ask due to there seems to be no question that not all files copy sometimes with recomendations to use other methods.

Keith Hugginswww.LivingViLife.com | [email="Keith.Visalus@gmail.com"]Keith.Visalus@gmail.com[/email]Want to automate your weightloss and fitness? I lost 20 pounds and 5 inches across my belly in 8 weeks without exercise!Check out my website or shoot me a email for more information

Link to comment
Share on other sites

There is nothing wrong with the function but there are multiple reasons why if might not work.

For example you might not have permission to writ to a certain dir, or an attribute might make

copying the file difficult, and more.

It is your responsibility as the coder to check for these things and address them.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
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
 Share

  • Recently Browsing   0 members

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