batch script to backup saves

Discussion in 'Other Flashing Hardware & Software' started by dipasqma, Aug 13, 2006.

Aug 13, 2006

batch script to backup saves by dipasqma at 2:03 AM (4,590 Views / 0 Likes) 26 replies

  1. dipasqma
    OP

    Newcomer dipasqma Newbie

    Joined:
    Jun 21, 2006
    Messages:
    6
    Country:
    United States
    I'm too lazy to manually backup my saves so I made a simple batch script to do it for me. Posting it here in case someone finds it useful. It might work on flash carts other than the G6L, I don't know. I've never used another cart.

    The script:
    Code:
    @ECHO OFF
    
    copy "%2:\%1\*.0" %3 >nul
    copy "%2:\%1\*.1" %3 >nul
    copy "%2:\%1\*.2" %3 >nul
    
    if /i %1 equ nds del %3\wrg*
    Hey, I did say it was simple. Download here but note that this a standard residential cable connection so who knows what kind of reliability I'll get. Anyway...
    Parameter 1 is whether the save is "gba" or "nds".
    Parameter 2 is the drive letter of the G6L. For me it would be "e".
    Parameter 3 is the folder to save to so for me it is "C:\Documents and Settings\Mark\Desktop\Saves\NDS" with the quotes INCLUDED (if you couldn't tell the other parameters are meant w/o quotes).

    Anyone who knows how to use this from the commandline can probably stop reading now but note that I recommend creating a shortcut to run the script as there is no error checking.

    *** edit ***
    Parameters are, in this case, information passed to the script when the script gets run. The parameters are separated by spaces. The last parameter, the location to store the saves, may have spaces in the folder names so by enclosing the location in quotes, spaces can be allowed. So to run the script from the commandline or from a shortcut, you need to:
    * specify the location and name of the script (this is already set up for you if you create a shortcut)
    * SPACE
    * specify either GBA or NDS for the type of save (this is used in determining where the saves are on the G6L, case doesn't matter)
    * SPACE
    * specify the drive letter of the G6L (again, case doesn't matter)
    * SPACE
    * specify the location to put the saves
    *** /edit ***

    To create:
    1. Download from: backup_g6l_saves.bat
    -or-
    1. Copy the script into notepad.
    2. Save as whatever name you want with the extension ".bat". Set "Save as type" to "All Files". Example: backup_g6l_saves.bat

    To set up:
    1. Create the folder to store the saves.
    2. Right-click the script and select "Create Shortcut".
    3. Rename the shortcut if you wish.
    4. Right-click the shortcut and select "Properties".
    5. In the Target textbox, enter the parameters AFTER what is already in the textbox. Let me know if the example doesn't explain it well enough. In general, the textbox goes as: "" ""
    Example:
    Code:
    "C:\Documents and Settings\Mark\Desktop\Saves\backup_g6l_saves.bat" nds e "C:\Documents and Settings\Mark\Desktop\Saves\NDS"
    6. Click OK.
    7. Repeat 1-6 for the GBA saves.

    To run:
    1. Double-click the shortcut. That's it.

    * Existing saves get overwritten. If a save exists in the folder and the game and its saves are NOT on the G6L, then the saves will not be deleted. In my eyes, the functionality of this script is very intuitive. Regardless, I'm not responsible for lost saves so don't bother yelling at me as there is nothing I can do about it.
    * These steps do work for me even if they somehow don't for you. I'll check back tomorrow or some time if anyone who cares needs help.
    * I only spent about an hour total for doing the script and this thread so don't expect this to be of professional quality or absolutely perfect.

    Enjoy [​IMG]

    (edit #2: updated links)
     


  2. antihaxer

    Newcomer antihaxer Advanced Member

    Joined:
    Jul 3, 2006
    Messages:
    94
    Country:
    United States
    Very nice. Will test when I get my g6 Lite. Always good to back up your saves incase you g6 gets corrupted. Some people might not know what parameters are or what you are talking about so you might want to add a more noob friendly guide.
     
  3. saxamo

    Member saxamo Spaaaaace!

    Joined:
    Aug 6, 2006
    Messages:
    775
    Location:
    NYC
    Country:
    United States

    *sheepishly raises hand*
     
  4. Lily

    Former Staff Lily One Scary Lady

    Joined:
    Jun 18, 2004
    Messages:
    5,727
    Location:
    British Columbia
    Country:
    Canada
    By 'parameter', he's refering to the %1, %2 & %3 items in the batch file.
     
  5. zone97

    Member zone97 GBAtemp Fan

    Joined:
    Feb 16, 2005
    Messages:
    466
    Location:
    Eastern Time zone
    Country:
    United States
    Even more simple... Download mirror folders. Then whenever you plug in your sd card, it will detect that folder and save the files yo a place you specified. all automatically you dont have to click anything.
     
  6. antihaxer

    Newcomer antihaxer Advanced Member

    Joined:
    Jul 3, 2006
    Messages:
    94
    Country:
    United States
    Except the G6 Lite does not have a sd card in it.....
     
  7. dipasqma
    OP

    Newcomer dipasqma Newbie

    Joined:
    Jun 21, 2006
    Messages:
    6
    Country:
    United States
    Like antihaxer said, the G6L doesn't have sd. Regardless, Windows isn't my primary OS (I run Windows only for the G6L under VPC on OS X) and was unaware such software existed for it. I should have assumed someone somewhere made free software that would do that but didn't think of it. Since I have a computer science background, I would personally find it easier to write this script then to download 3rd party software and configure it. Anyway, it is always good to point out alternatives that might be easier for some. To each his own.
     
  8. cyfaws

    Newcomer cyfaws Member

    Joined:
    Feb 18, 2005
    Messages:
    25
    Country:
    Sweden
    Seems to be working perfectly, thank you dipasqma!
     
  9. beedog19

    Member beedog19 GBAtemp Fan

    Joined:
    Feb 4, 2006
    Messages:
    386
    Location:
    Sunny Southern California
    Country:
    United States
    Just tried it out and it worked for me too, thanks! I just followed your easy to follow directions step for step and it worked perfectly!
     
  10. Seeker108

    Member Seeker108 GBAtemp Regular

    Joined:
    Jun 28, 2006
    Messages:
    121
    Country:
    Canada
    Works great! Thank you very much.
     
  11. SlyGuy

    Member SlyGuy GBAtemp Fan

    Joined:
    Aug 4, 2006
    Messages:
    396
    Country:
    Canada
    dipasqma, this is a great little utility! I have one request, if I may. Would it be possible for you to add to the script the ability to backup the GBA instant saves as well, please? I like to use them from time to time and it would be nice to backup all 6 saves in one click.

    Thank-you very much for this script!
     
  12. outphase

    Member outphase Custom title

    Joined:
    Nov 21, 2005
    Messages:
    1,218
    Country:
    United States
    batch executables can be edited on your own.
     
  13. SlyGuy

    Member SlyGuy GBAtemp Fan

    Joined:
    Aug 4, 2006
    Messages:
    396
    Country:
    Canada
    Yes, I know. However, I don't know how to write this type of script.
     
  14. outphase

    Member outphase Custom title

    Joined:
    Nov 21, 2005
    Messages:
    1,218
    Country:
    United States
    copy "%2:\%1\*.0" %3 >nul
    copy "%2:\%1\*.1" %3 >nul
    copy "%2:\%1\*.2" %3 >nul

    if these copy *.0 *.1 and *.2, how do you think you can add *.is0 *.is1 and *.is2?
     
  15. Vidnez

    Newcomer Vidnez Advanced Member

    Joined:
    Jul 31, 2006
    Messages:
    54
    Country:
    if /i %1 equ nds del %3\wrg*


    what exactlily do this command?
     
  16. pubjoe

    Member pubjoe GBAtemp Regular

    Joined:
    Jul 17, 2006
    Messages:
    110
    Country:
    United Kingdom
    Just wondering about that last line: if /i %1 equ nds del %3\wrg*

    shouldn't it read: if /i %1 equ %1 del %3\wrg* ?

    ...For example; in my .BAT, if I am backing up GBA, should I have:

    if /i GBA equ nds del "D:\Emulator\Nintendo DS\save backup\GBA"\wrg*
    (as per your instructions)

    OR:
    if /i GBA equ GBA del "D:\Emulator\Nintendo DS\save backup\GBA"\wrg*
    (notice that I have changed "nds" to GBA)

    ?

    Also, (I don't really understand the last line), will all my saves be overwritten each time I run it, or do they only get overwritten if they have changed. The first time I tried, they all backed up, but if I run the program again, nothing happens. Is it not deleting the duplicate files like it should, or is it supposed to do nothing (unless file information has changed)?

    Hope my questions made sense.

    Btw, I am running this .bat file...
    Code:
    @ECHO OFF
    
    copy "\NDS\*.0" "D:\Emulator\Nintendo DS\save backup\NDS" >nul
    copy "\NDS\*.1" "D:\Emulator\Nintendo DS\save backup\NDS" >nul
    copy "\NDS\*.2" "D:\Emulator\Nintendo DS\save backup\NDS" >nul
    
    if /i NDS equ nds del "D:\Emulator\Nintendo DS\save backup\NDS"\wrg*
    
    copy "\GBA\*.0" "D:\Emulator\Nintendo DS\save backup\GBA" >nul
    copy "\GBA\*.1" "D:\Emulator\Nintendo DS\save backup\GBA" >nul
    copy "\GBA\*.2" "D:\Emulator\Nintendo DS\save backup\GBA" >nul
    
    if /i GBA equ nds del "D:\Emulator\Nintendo DS\save backup\GBA"\wrg*
    ...Straight from my G6 ROOT folder. I don't specify a drive letter as my G6's drive letter often changes (due to other hardware).

    it seems to work to backup saves once, but I don't know if it will overwrite properly, and if I have that last line written correctly?

    Thanks.
     
  17. SlyGuy

    Member SlyGuy GBAtemp Fan

    Joined:
    Aug 4, 2006
    Messages:
    396
    Country:
    Canada
    Okay, okay, I get it! This is the code I came up with. Please let me know if there are any glaring errors that will mess up my saves/system. BTW, do I need to keep that "@ ECHO OFF" in there?

    Thanks!

    @ECHO OFF

    copy "L:\gba\*.0" "C:\Documents and Settings\Owner\My Documents\DS Stuff\Saves and Icons\GBA Saves and Icons" >nul
    copy "L:\gba\*.1" "C:\Documents and Settings\Owner\My Documents\DS Stuff\Saves and Icons\GBA Saves and Icons" >nul
    copy "L:\gba\*.2" "C:\Documents and Settings\Owner\My Documents\DS Stuff\Saves and Icons\GBA Saves and Icons" >nul

    copy "L:\gba\*.is0" "C:\Documents and Settings\Owner\My Documents\DS Stuff\Saves and Icons\GBA Saves and Icons" >nul
    copy "L:\gba\*.is1" "C:\Documents and Settings\Owner\My Documents\DS Stuff\Saves and Icons\GBA Saves and Icons" >nul
    copy "L:\gba\*.is2" "C:\Documents and Settings\Owner\My Documents\DS Stuff\Saves and Icons\GBA Saves and Icons" >nul

    if /i gba equ nds del "C:\Documents and Settings\Owner\My Documents\DS Stuff\Saves and Icons\GBA Saves and Icons"\wrg*
     
  18. dipasqma
    OP

    Newcomer dipasqma Newbie

    Joined:
    Jun 21, 2006
    Messages:
    6
    Country:
    United States
    Sorry for the lateness, haven't been on the site for over a week.

    About
    Code:
    if /i %1 equ nds del %3\wrg*
    On my card and only in the NDS folder, I have a file called "wrg_rtggd.0??" where the ? are unidentified characters. To be honest I have no idea what this file is for but it gets backed up when the first copy command runs (so along with all the *.0 saves). I see no need to back it up so the line simply deletes the file if you're backing up nds saves. This is merely a personal preferance so feel free remove the delete completely. The delete command doesn't have to run when backing up gba saves because no such file exists in the gba folder. I considered not adding that line when posting this thread but I figured I would get a reply or 2 asking why some strange file was being backed up. Damned if you do, damned if you don't. I should have just explained it in my first post.

    pubjoe:
    About overwriting: Saves will only be overwritten if a save of the same name exists on the G6L. I.e.
    Say you have 2 games: Mario Kart and Castlevania. All saves are backed up.
    You get rid of Castlevania but add Phoenix Wright.
    When backing up the saves again, the Mario Kart saves are updated to the version on the G6L (so they are overwritten). Castlevania saves are left alone as no Castlevania saves are on the G6L anymore. Phoenix Wright saves are backed up for the first time.

    Code:
    if /i %1 equ %1 del %3\wrg*
    simply doesn't make sense because %1 will always be equal to %1. That line is essentially the same as
    Code:
    del %3\wrg*
    in that the delete will run every time the script is executed.

    Code:
    if /i GBA equ nds del "D:\Emulator\Nintendo DS\save backup\GBA"\wrg*
    doesn't make much sense either. I'm guessing you don't know much about batch scripts so I'll try to explain what's going on. Note I'm not good at explaining this type of thing so it might not make much sense if you have no programming experience.

    if compares 2 strings (text) or numbers and runs a command if the result of the comparison is true.
    /i tells the if command to compare strings while ignoring case (i.e. with /i "NDS" and "nds" are considered equal while without the /i "NDS" does NOT equal "nds")
    GBA is the first string to compare
    equ tells if that it should test for the two strings to be equal (as opposed to, say, greater than or equal to which would be "gte")
    nds is the second string to compare

    In this case, "GBA" will never equal "nds" so the delete command (del) will never run. But like I said at the beginning of this post, the delete doesn't have to run for gba saves as the file it would delete will never exist.

    About the .bat that you quoted, what you are looking for is:
    Code:
    @ECHO OFF
    
    copy "NDS\*.0" "D:\Emulator\Nintendo DS\save backup\NDS" >nul
    copy "NDS\*.1" "D:\Emulator\Nintendo DS\save backup\NDS" >nul
    copy "NDS\*.2" "D:\Emulator\Nintendo DS\save backup\NDS" >nul
    
    del "D:\Emulator\Nintendo DS\save backup\NDS\wrg*"
    
    copy "GBA\*.0" "D:\Emulator\Nintendo DS\save backup\GBA" >nul
    copy "GBA\*.1" "D:\Emulator\Nintendo DS\save backup\GBA" >nul
    copy "GBA\*.2" "D:\Emulator\Nintendo DS\save backup\GBA" >nul
    Changes are:
    1. The leading backslash for the source files to copy is not needed (perhaps the leading backslash would work but I don't know if Windows actually recognizes a starting backslash as root, the change I made I definitely know works though).
    2. I removed the if statement completely. It was only there in my script because if backing up gba saves then the delete doesn't have to run. In your case since nds saves are always backed up, you might as well remove the if since all it does is waste a cpu cycle or 2.
    3. I completely removed the last line for reasons I mentioned above which again is that no file beginning with "wrt" is backed up for gba saves so no delete is needed.

    If that script is run from the root of the G6L then all nds and gba saves should be backed up to your folder.

    I hope that answers everything. Lemme know otherwise.

    GamerGuyDude:

    The script you gave looks fine and shouldn't mess up your saves or system. The only change I would make would be to remove the last line with the if statement because the line isn't needed when backing up gba saves.

    And, yes, you should keep @ECHO OFF in the script (although it doesn't REALLY matter). If you remove it, the script will output every command before they are executed. This is usually only helpful if you're trying to fix a script that doesn't work properly and since your script should work, removing the line will only slow down your script slightly.
     
  19. SlyGuy

    Member SlyGuy GBAtemp Fan

    Joined:
    Aug 4, 2006
    Messages:
    396
    Country:
    Canada
    Thanks! Something happened to my Trauma Centre save though [​IMG] I'm not sure what, but all the saves are blank now! I'm not sure what caused this. Either it's an error in the script or maybe I wrote over the saves with a freshly burned copy of Trauma...

    Either way it sucks... though I did finish the game last night. Guess I'll never do the X missions...
     
  20. Vidnez

    Newcomer Vidnez Advanced Member

    Joined:
    Jul 31, 2006
    Messages:
    54
    Country:

    When you copy a game onto the G6 lite the U-Disk creates a new saves for the game, so maybe after you copied the game you run the script and overwrited your saves with the blank saves.
     

Share This Page