MidwayMonster Posted January 20, 2012 Share Posted January 20, 2012 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 More sharing options...
Skitty Posted January 20, 2012 Share Posted January 20, 2012 (edited) Why not use DirCopy(@DesktopDir & "test1", @DesktopDir & "test2",1) If @error Then MsgBox(16,"Error","Error:"&@error) Edited January 20, 2012 by THAT1ANONYMOUSEDUDE Link to comment Share on other sites More sharing options...
MidwayMonster Posted January 20, 2012 Author Share Posted January 20, 2012 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 More sharing options...
kylomas Posted January 20, 2012 Share Posted January 20, 2012 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 Link to comment Share on other sites More sharing options...
KaFu Posted January 20, 2012 Share Posted January 20, 2012 wraithdu's has optional success verification via md5 build in. OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
MidwayMonster Posted January 21, 2012 Author Share Posted January 21, 2012 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 More sharing options...
JohnOne Posted January 21, 2012 Share Posted January 21, 2012 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 More sharing options...
kylomas Posted January 21, 2012 Share Posted January 21, 2012 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 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