Hacking Good automatic save backup program

Satangel

BEAST
OP
Member
Joined
Nov 27, 2006
Messages
10,307
Trophies
1
Age
31
Location
Bruges, Belgium
XP
1,525
Country
Belgium
Is there a program that automatic will backup all the .SAV's in a directory, when I ask it?
Cuz its a pain in the ass to copy all the .SAV's manually from my microSD to my PC...
And all my roms are in apart folders, so it should be able to scan inside the folders.

Tnx in adv.

Satangel
 

Scalpos

Member
Newcomer
Joined
Nov 27, 2006
Messages
10
Trophies
0
XP
94
Country
France
A simple batch / command line script is enough using 7zip or Rar

eg: "7z a YourR4Archive.7z *.sav" for R4 SAV files
"7z a YourG6Archive.7z *.0 *.1 *.2" for G6 files
Add the "-r" recurse subdirectories switch if needed
 

test84

GBAtemp's last ninja 2.
Member
Joined
Sep 8, 2006
Messages
3,698
Trophies
1
Website
gbatemp.net
XP
1,246
Country
Iran
i use a batch file, but i have to run it manually every time i connect my G6, donno how to put it in auto mode:

xcopy "f:\NDS\*.0" "d:\current g6\NDS\" /y
xcopy "f:\GBA\*.0" "d:\current g6\GBA\" /y
xcopy "f:\NDS\*.0" "d:\current g6\saves\NDS\" /y
xcopy "f:\GBA\*.0" "d:\current g6\saves\GBA\" /y
xcopy "f:\DSNOTES\*.BMP" "d:\current g6\DSNOTES\" /y
xcopy "f:\DSNOTES\*.BMP" "D:\0\My digital Paintings\DSNOTES" /y

xcopy "G:\NDS\*.0" "d:\current g6\NDS\" /y
xcopy "G:\GBA\*.0" "d:\current g6\GBA\" /y
xcopy "G:\NDS\*.0" "d:\current g6\saves\NDS\" /y
xcopy "G:\GBA\*.0" "d:\current g6\saves\GBA\" /y
xcopy "G:\DSNOTES\*.BMP" "d:\current g6\DSNOTES\" /y
xcopy "G:\DSNOTES\*.BMP" "D:\0\My digital Paintings\DSNOTES" /y


i would like to write a program to rename the old file and use numerics for later files, rather than replacing them, but its a little unnecessary, aint it?

and i donno how to xcopy and overwrite with the default switch to NO, instead of YES.
 

GTScelica93

Member
Newcomer
Joined
Oct 19, 2007
Messages
11
Trophies
0
XP
49
Country
United States
I use the following batch file to copy my saves:

QUOTE said:
for /f "Tokens=2-4 Delims=/ " %%a in ('date /t') do set mm=%%a & set dd=%%b & set yy=%%c
xcopy "f:\*.sav" "c:\NDS\Saves\%mm%%dd%%yy%" /y /f

I'm sure that it could be more clean, but I threw this together after a quick google search. It will create a folder by date (ex 10 31 2007) and place the saves in that folder.

Edit: The following seems to work a bit better:

:: variables
set drive=c:\
set backupcmd=xcopy /c /h /i /r /y
set folder=%date:~10,4%_%date:~4,2%_%date:~7,2%
%backupcmd% "f:\*.sav" "%drive%\NDS\Saves\%folder%"
 

Lexal

Well-Known Member
Newcomer
Joined
Apr 2, 2007
Messages
90
Trophies
0
XP
60
Country
You could place the batcfile in ur root of the memstick and create a file named autorun.inf
In that file, write:
[autorun]
open=Ur_batch.file
icon=icon 4 ur drive.ico

(included a little extra
tongue.gif
)
 

enigmaindex

the Scarecrow
Member
Joined
Oct 11, 2007
Messages
662
Trophies
0
Age
32
Location
Gold Coast, Australia
Website
www.zomganime.com
XP
125
Country
Thanks for that i'll be sure to try that later on.

EDIT: Okay i got everything working. Heres what my .bat file says:

QUOTE said:
:: variables
set drive=c:\
set backupcmd=xcopy /c /h /i /r /y
set folder=%date:~10,4%_%date:~4,2%_%date:~7,2%
%backupcmd% "roms\*.sav" "%drive%\Documents and Settings\Azza\My Documents\AAron\Games\NDS\Saves\%folder%"

And here it was my autorun.inf file says

QUOTE[autorun]
open=backupsaves.bat
action=Back Up Your Nintendo DS Saves
icon=C:\WINDOWS\system32\shell32.dll,7

(NOTE: both files are in the root directory of my Micro SD)

I added an extra line which is "action=Back Up Your DS Saves"
and here is the result of it

Autoplay.png


As you can see i implemented it into the Autoplay option. This is very handy as pretty much just click on the "Back Up Your Nintendo DS Saves" and it will run the .bat and copy the saves to where ever you specified it to go. It's alot easier for me and thought i would share it with you.
 

test84

GBAtemp's last ninja 2.
Member
Joined
Sep 8, 2006
Messages
3,698
Trophies
1
Website
gbatemp.net
XP
1,246
Country
Iran
1)the point is that my G6 doesnt pop up the Autorun Box anymore! donno why. (there is Autoron.inf file in root, but doesnt show up, i have to right click and select Autorun to see the window)

[EDIT]
thnx, that ACTION line saved me!

2)is there a defualt NO for xcopy? i want to backup my .NDS and .GBA files but i just want xcopy to copy files that are not on my hard already.
like xcopy "G:\*.gba" "d:\current g6\gba" /n so it will just copy .gba files that are not on my hard and not to copy 500mg everytime i backup.
 

MadBob

Nostalgia ain't what it used to be!
Member
Joined
Nov 6, 2002
Messages
1,555
Trophies
2
Website
Visit site
XP
731
Country
try xcopy /m

I seem to remember that from my MS-DOS days as how we did incremental backup's, it checks for the archive data bit and resets it after copying the file, once you use the game (and it resaves the file) xcopy /m will see the file needs copying next time.
 

MadBob

Nostalgia ain't what it used to be!
Member
Joined
Nov 6, 2002
Messages
1,555
Trophies
2
Website
Visit site
XP
731
Country
OK as the above batch file wouldn't work on UK date formats I have re written it and added an explanation of what it all does for people not used to MS-DOS (yes I am an old fart) I have used a quote to let me put the actual commands in bold.

QUOTE said:
:: Note this is set to work for the UK date format.
:: if not working correctly for you, open a CMD prompt and type "echo %date%" which shows 10/11/2007 on my PC,
:: the "folder" variable below starts at character 0 for 2 counts (so it uses the "1" and "0") then uses a "." as a separator,
:: moves to character 3 for 2 counts ("1" and "1") then uses a "." moves to character 6 for 4 counts (so it uses "2" and "0" and "0" and "7")
:: this means folder=10.11.2007 (or whatever the date is when the batch file is run)
set folder=%date:~0,2%.%date:~3,2%.%date:~6,4%
:: the "PCdrive" variable below can be changed to suit your drive and destination folder
set PCdrive=N:\GBA\NDS_Saves
:: the "backupcmd" variable below sets the Xcopy functions (/d checks the source folder for a newer save version)
set backupcmd=xcopy /c /h /i /r /y /d
:: the "SRCdrive" variable is to tell the batch file where to copy from, my games are in the folder NDS
set SRCdrive=NDS\*.sav
:: this simply connects all the variables and is the same as typing (xcopy /c /h /i /r /y /d NDS\*.sav N:\GBA\NDS_Saves\10.11.2007)
%backupcmd% %SRCdrive% %PCdrive%\%folder%
:: this creates a folder with the current date (if not already there) and copies from the NDS folder to the date folder created
:: overwriting the existing save if the DS version is newer.

I have stopped autorun on my system so needed a different approach, my batch file is called backme.cmd and this is the contents of my Autorun.inf

[autorun]
open=
shell\DSBackup=Backup DS Saves
shell\DSBackup\command=backme.cmd

this adds the option Backup DS Saves to the right click context menu.
 

myuusmeow

Well-Known Member
Member
Joined
Jun 24, 2007
Messages
1,646
Trophies
0
Website
google.com
XP
327
Country
United States
Can you add something to the inf file to make it open up drive N: when it is done?

(BTW, awesome. Never knew I used up about 30mB on saves only. XD)
 

MadBob

Nostalgia ain't what it used to be!
Member
Joined
Nov 6, 2002
Messages
1,555
Trophies
2
Website
Visit site
XP
731
Country
Can you add something to the inf file to make it open up drive N: when it is done?

(BTW, awesome. Never knew I used up about 30mB on saves only. XD)


Try this command.

QUOTE said:
:: the command below opens the folder your saves have been copied into
smile.gif

:: the DOS CMD window will stay visible until you close the explorer window though
frown.gif

explorer "%pcdrive%\%folder%"
:: However if that is an issue to you download CMDOW from http://www.commandline.co.uk/cmdow/
:: add this line at the top of your batch file, this hides the DOS box but still lets it run in the background
:: you need cmdow.exe on your MicroSD as well as the batch file
cmdow @ /hid

so the whole batch file will look like...

QUOTE
:: hides the dos commands
@echo off
:: hides the dos window, needs cmdow.exe from http://www.commandline.co.uk/cmdow/
cmdow @ /hid
:: titles the window if you aren't hiding it
title Backup NDS Saves
:: sets the folder name to the current date
set folder=%date:~0,2%.%date:~3,2%.%date:~6,4%
:: sets the destination drive
set PCdrive=N:\GBA\NDS_Saves
:: sets how Xcopy works
set backupcmd=xcopy /c /h /i /r /y /d
:: sets source drive (where your saves are on your MicroSD) and the filetype you are copying
set SRCdrive=NDS\*.sav
:: does the work
%backupcmd% %SRCdrive% %PCdrive%\%folder%
:: opens the destination folder
explorer "%pcdrive%\%folder%"
 

jakeruston

Well-Known Member
Member
Joined
Jul 27, 2007
Messages
136
Trophies
0
Website
Visit site
XP
135
Country
Can you add something to the inf file to make it open up drive N: when it is done?

(BTW, awesome. Never knew I used up about 30mB on saves only. XD)


Try this command.

QUOTE said:
:: the command below opens the folder your saves have been copied into
smile.gif

:: the DOS CMD window will stay visible until you close the explorer window though
frown.gif

explorer "%pcdrive%\%folder%"
:: However if that is an issue to you download CMDOW from http://www.commandline.co.uk/cmdow/
:: add this line at the top of your batch file, this hides the DOS box but still lets it run in the background
:: you need cmdow.exe on your MicroSD as well as the batch file
cmdow @ /hid

so the whole batch file will look like...

QUOTE:: hides the dos commands
@echo off
:: hides the dos window, needs cmdow.exe from http://www.commandline.co.uk/cmdow/
cmdow @ /hid
:: titles the window if you aren't hiding it
title Backup NDS Saves
:: sets the folder name to the current date
set folder=%date:~0,2%.%date:~3,2%.%date:~6,4%
:: sets the destination drive
set PCdrive=N:\GBA\NDS_Saves
:: sets how Xcopy works
set backupcmd=xcopy /c /h /i /r /y /d
:: sets source drive (where your saves are on your MicroSD) and the filetype you are copying
set SRCdrive=NDS\*.sav
:: does the work
%backupcmd% %SRCdrive% %PCdrive%\%folder%
:: opens the destination folder
explorer "%pcdrive%\%folder%"

Your version worked. Thanks
smile.gif
 

striderx

Well-Known Member
Member
Joined
Jun 16, 2007
Messages
239
Trophies
0
Location
USA
XP
220
Country
United States
To everyone that've been contributing to this thread, thanks... These are great little solutions for making savegame backups easier.

I'd like to ask for a couple of additional enhancements. I'd add these myself, but my own DOS library was disbanded long ago and google searches for the right format for the parameters in the commands aren't delivering what I'm looking for.

In the set folder line, I'd like to add the volume name of the backup source (microSD card) at the beginning of the parameter string before the date and the time (HH:MM:SS) following the date.

The resulting folder name should look like this: [striderx 20080127 170723]

I've got several microSD cards, each with a different volume name (for each of my kids and myself). Some savefiles of the same name are on every one one of those cards so I want this to avoid collisions of the backups and also easily identify whose is whose by using the volume name. By adding the timestamp it would then support multiple backups during the same day (yes, it happens!) and by using the /M switch with xcopy, then only files changed since the last backup get copied during the current one.

Can one of you help please?

TIA,

striderx

UPDATE: I've been successful in adding the time to the folder name by appending the following to the set folder command:

_%time:~0,2%%time:~3,2%%time:~6,2%

Using this command:

set folder=%date:~10,4%%date:~4,2%%date:~7,2%_%time:~0,2%%time:~3,2%%time:~6,2%

I get a folder named like this:

20080127_223621

Still haven't cracked the volume name issue though. If I add the "vol" parameters using a command that looks like this:

set folder=%vol:~0,20%_%date:~10,4%%date:~4,2%%date:~7,2%_%time:~0,2%%time:~3,2%%time:~6,2%

I get this in response: (K: is the drive letter of my microSD card)

K:\>set folder=~1,2date:~10,4%date:~4,2%date:~7,2time:~0,2%time:~3,2%time:~6,2

K:\>xcopy /c /h /i /r /y /m "K:\*.sav" "\\Px-eh\disk\ROMS\\DS Save Backup\~1,2date:~10,4%date:~4,2%date:~7,2time:~0,2%time:~3,2%time:~6,2\"
Invalid drive specification

:: hides the dos commands
@echo off
:: hides the dos window, needs cmdow.exe from http://www.commandline.co.uk/cmdow/
cmdow @ /hid
:: titles the window if you aren't hiding it
title Backup NDS Saves
:: sets the folder name to the current date
set folder=%date:~0,2%.%date:~3,2%.%date:~6,4%

:: sets the destination drive
set PCdrive=N:\GBA\NDS_Saves
:: sets how Xcopy works
set backupcmd=xcopy /c /h /i /r /y /d
:: sets source drive (where your saves are on your MicroSD) and the filetype you are copying
set SRCdrive=NDS\*.sav
:: does the work
%backupcmd% %SRCdrive% %PCdrive%\%folder%
:: opens the destination folder
explorer "%pcdrive%\%folder%"
 

ACQ

Well-Known Member
Newcomer
Joined
Jul 29, 2007
Messages
61
Trophies
0
Location
Spokane, WA
Website
Visit site
XP
55
Country
United States
I'm not sure you can achieve what you want without getting into how Windows assigns unique identifiers to each removable drive. Maybe I'm misunderstanding the trouble you're experiencing, but would using the subst command to create different virtual drives for each microSD do the trick?
 

striderx

Well-Known Member
Member
Joined
Jun 16, 2007
Messages
239
Trophies
0
Location
USA
XP
220
Country
United States
I'm not sure you can achieve what you want without getting into how Windows assigns unique identifiers to each removable drive. Maybe I'm misunderstanding the trouble you're experiencing, but would using the subst command to create different virtual drives for each microSD do the trick?

Well, I was trying to follow the example provided by the original batch file:

When you execute the "DATE", "TIME" and "VOL" commands in "DOS box" of Windows XP you the the following in return:

Microsoft Windows XP [Version 5.1.2600]
 Copyright 1985-2001 Microsoft Corp.

C:\>date
The current date is: 01/27/2008
Enter the new date: (mm-dd-yy)

C:\>time
The current time is: 22:36:21.19
Enter the new time:

C:\>vol
Volume in drive F is STRIDERX
Volume Serial Number is 0000-0000

C:\>

The original batch file pieced together the date in this manner:

set folder=%date:~10,4%%date:~4,2%%date:~7,2%_%time:~0,2%%time:~3,2%%time:~6,2%

%date:~10,4% --- this returns the portion of the DATE command output starting at character position 10 and 4 characters after that which corresponds to the year. In this case it would be 2008.

This then gets concatenated with %date:~4,2% --- which returns the portion starting at character position 4 and 2 characters after that corresponding to the month, or 01.

Finally %date:~7,2% produces the day of the month.

Put those all together and you get this: 20080127

Do the samer thing for the TIME command, place an underbar (_)in there and this is the result: 20080127_223621

Well I want to use the VOL command the same way and use the output in naming the folder in the same way the DATE and TIME were used.

I can't seem to find the right incantation of %, ~, and numbers to do this without throwing an error.

What I'm going to try later is to see if I can't hardcode the volume ID in the batch file rather than having it generated on the fly each time I run it.

Using the examples above I want that folder to be named STRIDERX_20080127_223621

This would be fine if it works, but then the batch file is no longer portable without modification. C'est la vie...

striderx
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    SylverReZ @ SylverReZ: @OctoAori20, Cool. Same here.