Sign in to follow this  
Followers 0
MidwayMonster

Copy Verification

8 posts in this topic

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Why not use

DirCopy(@DesktopDir & "test1", @DesktopDir & "test2",1)

If @error Then MsgBox(16,"Error","Error:"&@error)

Edited by THAT1ANONYMOUSEDUDE

Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

MidwayMonster,

Do a search for "robocopy" for some alternative copy techniques deployed by other forum members.

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

MidwayMonster,

The alternative suggestions are nothing more than an opportunity to see what other have already done. No since in re-inventing the wheel.

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

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