Vacuus Posted April 15, 2007 Share Posted April 15, 2007 Heya all. I'm a C++ programmer by trade, and needed a way to backup my USB drive. After mucking around with Boost::Filesystem for a while, I quite accidentally stumbled upon AutoIt. I was impressed at how easy it was to use - in an hour, I've written a script that (should) back up my Flash Drive completely, and then update it appropriately. However, I'm having some issues. I've been able to backup the drive, and keep settings in an ini file, but I can't seem to "Update" the USB correctly. I'm using DirCopy, and would like to go from E:\ to H:\, however this never seems to happen. The strangest thing is, that when I change E:\ to a subdirectory, it'll work great (i.e E:\C++), however I already know I can copy from a root directory, as I've been doing so with the previous copy call (From H:\ to My Documents)... Here's the copy command (and error checking) I'm using, if it helps: If StringInStr($CopyDir, "\", 0, -1) == 0 Then $ret &= "\" EndIf $ret = DirCopy($CopyDir, $usb&":\", 1) If $ret == 0 Then MsgBox(48, "Error!", "Couldn't copy from "&$CopyDir&" To "&$usb&":\") Exit EndIf I'll attach the entire script as well. Cheers.flashback.au3 Link to comment Share on other sites More sharing options...
PsaltyDS Posted April 15, 2007 Share Posted April 15, 2007 I'm not sure I get your use of $ret here, adding "\" to it instead of $CopyDir. Since you only do one immediate compare on the return value, it doesn't need to be saved in a variable anyway. How about this instead: If Not StringInStr($CopyDir, "\") Then $CopyDir &= "\" If DirCopy($CopyDir, $usb & ":\", 1) Then MsgBox(64, "Debug: Success", "Successfull copy from " & $CopyDir & " To " & $usb & ":\") Else MsgBox(16, "Debug: Error", "Couldn't copy from " & $CopyDir & " To " & $usb & ":\") Exit EndIf Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
eltorro Posted April 15, 2007 Share Posted April 15, 2007 (edited) According to the help file, CopyDir does NOT want the trailing backslash.So I would think the following would be what you want.If StringRight(StringStripWS($CopyDir,2),1) = "\" Then $CopyDir =StringTrimRight($CopyDir,1) If DirCopy($CopyDir, $usb & ":", 1) Then MsgBox(64, "Debug: Success", "Successfull copy from " & $CopyDir & " To " & $usb & ":") Else MsgBox(16, "Debug: Error", "Couldn't copy from " & $CopyDir & " To " & $usb & ":") Exit EndIfEdit: spelling. Edited April 15, 2007 by eltorro Regards, [indent]ElTorro[/indent][font="Book"] Decide, Commit, Achieve[/font]_ConfigIO.au3Language Translation --uses Google(tm) MsgBox Move XML wrapper UDF XML2TreeView Zip functionality Split your GUI Save Print ScreenZipPluginEdit In Place listviewSome of my scripts on Google code Link to comment Share on other sites More sharing options...
Vacuus Posted April 15, 2007 Author Share Posted April 15, 2007 (edited) PSaltyDS: $ret is a habit from a bunch of other languages... I know, I shouldn't Correct me if I'm wrong, but, I think, using StringInStr($CopyDir, "\") instead of StringInStr($CopyDir, "\", -1), could possibly add a trailing backslash when it's not needed (I think - more than a little tired here), doesn't matter anyway Strangely, Eltorro, your suggestion just seemed to copy files from the working directory of the script :S. I'm all out of time at the moment, but I'll have a bit of a play around and get back to you with what happens.Cheers, and thanks for all of your help Edit: Wait, how does AutoIt Handle file copying anyway? The script itself is inside the CopyDir... I remember DOS had a similar thing, where you could copy only from your working directory on each partition.. Doubt this is related, as AutoIt seems to use Windows API calls, however you never know... (I suppose, you did answer my question though ) Edited April 15, 2007 by Vacuus Link to comment Share on other sites More sharing options...
MHz Posted April 15, 2007 Share Posted April 15, 2007 This thread prompted me to test and post a bug report on DirCopy to the root directory. You will need a trailing backslash for a drive letter only, which is used for destination. E.g. "c:\".Bug report.http://www.autoitscript.com/forum/index.php?showtopic=44233 Link to comment Share on other sites More sharing options...
Zedna Posted April 15, 2007 Share Posted April 15, 2007 @Vacuus I have nothing for you about DirCopy problembut I looked at you USB backup script (it's nice)and find that you can use DriveGetDrive() function instead of your $alph[] array. Resources UDF ResourcesEx UDF AutoIt Forum Search 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