Diana (Cda) Posted January 27, 2008 Share Posted January 27, 2008 (edited) Well, Blunderwoman strikes again <g>. Can't get this one to work though it's close. I'm doing a dircopy to back up a folder on the C drive. I'm getting the right target folder (with correct date and time stamp) but it gets created as an empty folder. Instead, the data is being copied into a separate, created folder labelled "1" each time script is invoked. So don't know where I'm screwing up. I should end up with one folder, the date- and time-stamped target folder, holding the backups! <g> Here is the code: $foldername = DirCreate("L:\WEReplacements\WERepl- PowerDesk Pro 6\APP- PowerDesk Pro 6\BKP- Settings\PowerDeskFavorites- " & @YEAR & "." & @MON & "." & @MDAY & ", " & @HOUR & "h" & @MIN & "m" & @SEC & "s") DirCopy("C:\Documents and Settings\Administrator\Application Data\VCOM\PowerDesk", $foldername) Thanks! Edited February 7, 2008 by Diana (Cda) Link to comment Share on other sites More sharing options...
Squirrely1 Posted January 27, 2008 Share Posted January 27, 2008 (edited) This should keep you from overwriting a good backup and at least help make sure that one was created: $destination_Folder = "L:\WEReplacements\WERepl- PowerDesk Pro 6\APP- PowerDesk Pro 6" $destination_Folder &= "\BKP- Settings\PowerDeskFavs_" $destination_Folder &= @YEAR & "_" & @MON & "_" & @MDAY $source_Folder = "C:\Documents and Settings\Administrator\Application Data\VCOM\PowerDesk" $overwrite = 0 If FileExists($destination_Folder) Then $RetVal = MsgBox(262144+4096+32+3, "Backup", "The destination folder already exists. Overwrite?") If $RetVal = 6 Then $overwrite = 1 Else Exit EndIf EndIf $RetVal = DirCopy($source_Folder, $destination_Folder, $overwrite) If Not $RetVal Then MsgBox(262144+4096+64, "", "There was an error backing up PowerDesk favorites.") EndIf ; I don't care what they say, a folder path should be no longer than 90 char's ; and a folder name no longer than 22 characters in length. ; dots - "." - in a folder name are not such a good idea either I am unsure of the wisdom of using incremental backups as well. Edited January 27, 2008 by Squirrely1 Das Häschen benutzt Radar Link to comment Share on other sites More sharing options...
Bowmore Posted January 27, 2008 Share Posted January 27, 2008 Well, Blunderwoman strikes again <g>. Can't get this one to work though it's close. I'm doing a dircopy to back up a folder on the C drive. I'm getting the right target folder (with correct date and time stamp) but it gets created as an empty folder. Instead, the data is being copied into a separate, created folder labelled "1" each time script is invoked. So don't know where I'm screwing up. I should end up with one folder, the date- and time-stamped target folder, holding the backups! <g> Here is the code: $foldername = DirCreate("L:\WEReplacements\WERepl- PowerDesk Pro 6\APP- PowerDesk Pro 6\BKP- Settings\PowerDeskFavorites- " & @YEAR & "." & @MON & "." & @MDAY & ", " & @HOUR & "h" & @MIN & "m" & @SEC & "s") DirCopy("C:\Documents and Settings\Administrator\Application Data\VCOM\PowerDesk", $foldername)oÝ÷ Ù8ZK7ßú®¢×°«y«^ën®{5ûayØ«yËh¯,²Ëqë,~éeÉÊÞj×méÚ궩jØh~Ø^v*ÞrÚ+É«¢+ØÀÌØí½±É¹µôÅÕ½Ðí0èÀäÈí]IÁ±µ¹ÑÌÀäÈí]IÁ°´A½ÝÉͬAɼØÀäÈíA@´A½ÝÉͬAɼØÀäÈí -@´MÑÑ¥¹ÌÀäÈíA½ÝÉÍٽɥÑÌ´ÅÕ½ÐìµÀìeHµÀìÅÕ½Ðì¸ÅÕ½ÐìµÀì5=8µÀìÅÕ½Ðì¸ÅÕ½ÐìµÀì5dµÀìÅÕ½Ðì°ÅÕ½ÐìµÀì!=UHµÀìÅÕ½Ðí ÅÕ½ÐìµÀì5%8µÀìÅÕ½Ðí´ÅÕ½ÐìµÀìMµÀìÅÕ½ÐíÌÅÕ½Ðì(ÀÌØí¥MÑÑÕÌô¥É ÉÑ ÀÌØí½±É¹µ¤)%ÀÌØí¥MÑÑÕÌôÄQ¡¸(%¥É ½Áä ÅÕ½ÐíèÀäÈí½Õµ¹Ñ̹MÑÑ¥¹ÌÀäÈíµ¥¹¥ÍÑÉѽÈÀäÈíÁÁ±¥Ñ¥½¸ÑÀäÈíY =4ÀäÈíA½ÝÉͬÅÕ½Ðì°ÀÌØí½±É¹µ¤)¹% "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook Link to comment Share on other sites More sharing options...
Diana (Cda) Posted January 28, 2008 Author Share Posted January 28, 2008 This should keep you from overwriting a good backup and at least help make sure that one was created: $destination_Folder = "L:\WEReplacements\WERepl- PowerDesk Pro 6\APP- PowerDesk Pro 6" $destination_Folder &= "\BKP- Settings\PowerDeskFavs_" $destination_Folder &= @YEAR & "_" & @MON & "_" & @MDAY $source_Folder = "C:\Documents and Settings\Administrator\Application Data\VCOM\PowerDesk" $overwrite = 0 If FileExists($destination_Folder) Then $RetVal = MsgBox(262144+4096+32+3, "Backup", "The destination folder already exists. Overwrite?") If $RetVal = 6 Then $overwrite = 1 Else Exit EndIf EndIf $RetVal = DirCopy($source_Folder, $destination_Folder, $overwrite) If Not $RetVal Then MsgBox(262144+4096+64, "", "There was an error backing up PowerDesk favorites.") EndIf ; I don't care what they say, a folder path should be no longer than 90 char's ; and a folder name no longer than 22 characters in length. ; dots - "." - in a folder name are not such a good idea eitherThis is quite complex, but it works. I naturally had to change the folder structure to what I needed, so those 2 lines of code now look like this: $destination_Folder &= "\BKP- Settings\PowerDeskFavourites- " $destination_Folder &= @YEAR & "." & @MON & "." & @MDAY & ", " & @HOUR & "h" & @MIN & "m" & @SEC & "s"<g> I am unsure of the wisdom of using incremental backups as well.Understood. But sometimes necessary. I use seconds on these types of backups because sometimes I'm in the middle of heavy editing and might make several backups over a period of a few minutes because I think I'm done and find I'm not. Then I'll delete all but that last one. Thanks! Link to comment Share on other sites More sharing options...
Squirrely1 Posted January 28, 2008 Share Posted January 28, 2008 (edited) This is quite complex...You say my code is complex - I'm kind of an amatuer. The real coders here on the AutoIt forums know C++ and COM, they call API's using DLL's - heck, they even use machine code sometimes - and I can get lost pretty easily there. But thank-you for the thanks Diana (Cda) - (I guess that stands for .cda the file extension for audio CD's) Edited January 28, 2008 by Squirrely1 Das Häschen benutzt Radar Link to comment Share on other sites More sharing options...
Diana (Cda) Posted January 28, 2008 Author Share Posted January 28, 2008 You say my code is complex - I'm kind of an amatuer. The real coders here on the AutoIt forums know C++ and COM, they call API's using DLL's - heck, they even use machine code sometimes - and I can get lost pretty easily there. But thank-you for the thanks Diana (Cda) - (I guess that stands for .cda the file extension for audio CD's)Complex for me <g>. You're way ahead of me, then. Nope, Cda actually stands for Canada. <lol>Thanks. Link to comment Share on other sites More sharing options...
Diana (Cda) Posted January 29, 2008 Author Share Posted January 29, 2008 Thought I should close this thread up. End result for the backups at work is like this, which is nicer in one way than one at home. Setup is different and here I can @UserProfileDir rather than absolute paths: $destination_Folder = @UserProfileDir & "\Favorites\01\0WXP\APP- PowerDesk Pro 6" $destination_Folder &= "\BKP- Settings\PD6FavsWORK- " $destination_Folder &= @YEAR & "." & @MON & "." & @MDAY & ", " & @HOUR & "h" & @MIN & "m" & @SEC & "s" $source_Folder = @UserProfileDir & "\Application Data\VCOM\PowerDesk" $overwrite = 0 Send("F5") If FileExists($destination_Folder) Then $RetVal = MsgBox(262144+4096+32+3, "Backup", "The destination folder already exists. Overwrite?") If $RetVal = 6 Then $overwrite = 1 Else Exit EndIf EndIf $RetVal = DirCopy($source_Folder, $destination_Folder, $overwrite) If Not $RetVal Then MsgBox(262144+4096+64, "", "There was an error backing up PowerDesk favorites.") EndIf Send("F5")Works just great! I've left the error handling in re destination folder even though it's s highly unlikely in this case that it'll ever be an issue because of the time stamp format I use which includes seconds (which is why I do that). But good to keep that in there for future, other uses where I probably won't use the time stamp to that degree on folder names. Thanks. Link to comment Share on other sites More sharing options...
Diana (Cda) Posted February 7, 2008 Author Share Posted February 7, 2008 I decided to add additional error handling but ran into some trouble. I have the right idea, I think, I'm just stuck on the correct syntax. I suspect the $overwrite may be at fault, but I'm not exactly sure. Here's the code as it stands now: $destination_Folder = "L:\WEReplacements\WERepl- PowerDesk Pro 6\APP- PowerDesk Pro 6" $destination_Folder &= "\BKP- Settings\PD6FavsHOME- " $destination_Folder &= @YEAR & "." & @MON & "." & @MDAY & ", " & @HOUR & "h" & @MIN & "m" & @SEC & "s" $source_Folder = "C:\Documents and Settings\Administrator\Application Data\VCOM\PowerDesk" $overwrite = 0 Send("F5") If Not FileExists($destination_Folder) Then $RetVal = MsgBox(48,"DESTINATION folder error ...","The PowerDesk settings DESTINATION folder does not exist.") If $RetVal = 6 Then $overwrite = 1 Else Exit EndIf EndIf If Not FileExists($source_Folder) Then $RetVal = MsgBox(48,"SOURCE folder error ...","The PowerDesk settings SOURCE folder does not exist.") If $RetVal = 6 Then $overwrite = 1 Else Exit EndIf EndIf $RetVal = DirCopy($source_Folder, $destination_Folder, $overwrite) If Not $RetVal Then MsgBox(262144+4096+64, "", "There was an error backing up PowerDesk favorites.") EndIf Send("F5")I don't really need overwrite error handling as the time- and date-stamps should take care of duplication. There won't be any since the time-stamp includes seconds. But I don't know what to replace that with, or what to do about it. However, what is an issue is that either the source folder or the destination folder may sometimes have problems (i.e., esp. when I migrate to somewhere else or a change in the names of the folders). How can this code be changed so it would work, pls? Thanks! Link to comment Share on other sites More sharing options...
Diana (Cda) Posted February 10, 2008 Author Share Posted February 10, 2008 Hi. If Not FileExists($destination_Folder) Then $RetVal = MsgBox(48,"DESTINATION folder error ...","The PowerDesk settings DESTINATION folder does not exist.") If $RetVal = 6 Then $overwrite = 1 Else Exit EndIf EndIf If Not FileExists($source_Folder) Then $RetVal = MsgBox(48,"SOURCE folder error ...","The PowerDesk settings SOURCE folder does not exist.") If $RetVal = 6 Then $overwrite = 1 Else Exit EndIf EndIfThese are both the same in terms of variables or something in the syntax around them, I think, and I just don't know enough about variables to fix. Right now the script in the message above isn't working and I think the problem lies in this piece above quoted here. I'd just like to make this script work for any condition and prompting user when one of the 2 folders is missing, for whatever the reason, is best way to do this. Thanks. 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