View Single Post
Old 07-28-2014, 11:49 AM   #1
aston217
College Prospect
 
Join Date: Sep 2010
Batch file for backing up leagues

Here's the code I use to back up leagues. There are two versions, one for leagues I commish, one for leagues I don't. The example code I use here uses OSFL for the league name. The directory where you choose to backup to, of course, is entirely up to you. In this example it is C:\mybackupfolder\OSFL\ -- replace with whatever you like.

The batch file (as well as the VBS script file) must be placed in the %APPDATA%\Solecismic Software\Front Office Football Seven\ directory. You may create a shortcut to the batch file wherever you like.

2015-04-29 rev: make use of FOF7 import/export folders. Much better this way.

backup.bat (commish)

Run this AFTER saving & exporting the stage file. Otherwise, your "export" folder may not contain the save files.

Code:
@echo off for /f "tokens=1,2,3,5,6 usebackq delims=:/ " %%a in ('%date% %time%') do set TimeStamp=%%c-%%a-%%b_%%d%%e echo %TimeStamp% md "C:\mybackupfolder\OSFL\New" copy export\OSFL2007\* "C:\mybackupfolder\OSFL\New" md "C:\mybackupfolder\OSFL\New\imports" copy import\OSFL2007\* "C:\mybackupfolder\OSFL\New\imports" CScript zip.vbs "C:\mybackupfolder\OSFL\New" "C:\mybackupfolder\OSFL\New.zip" cd "C:\mybackupfolder\OSFL" rename New.zip "%TimeStamp%.zip" rd /q/s New

Note that the timestamp code is region-specific (I'm in the US). I just put in the first thing that I found worked for me. You'll likely have to do a little headachey googling if it doesn't produce the right timestamp for you.

zip.vbs
To perform the zipping, I use this code which I found online. It is Windows specific. You can easily rewrite the batch file without zipping if you like; just name the folder "%TimeStamp%" to begin with rather than "New". The current way creates the "New" folder, copies everything over, zips it up, and then deletes the "New" folder.

Code:
'Get command-line arguments. Set objArgs = WScript.Arguments InputFolder = objArgs(0) ZipFile = objArgs(1) 'Create empty ZIP file. CreateObject("Scripting.FileSystemObject").CreateTextFile(ZipFile, True).Write "PK" & Chr(5) & Chr(6) & String(18, vbNullChar) Set objShell = CreateObject("Shell.Application") Set source = objShell.NameSpace(InputFolder).Items objShell.NameSpace(ZipFile).CopyHere(source) 'Required! wScript.Sleep 8000

backup.bat (GM version)

Run this AFTER importing a new stage file. It will also backup your previous export (i.e, your export for the stage file you are currently backing up).

Code:
@echo off for /f "tokens=1,2,3,5,6 usebackq delims=:/ " %%a in ('%date% %time%') do set TimeStamp=%%c-%%a-%%b_%%d%%e echo %TimeStamp% md "C:\mybackupfolder\OSFL\New" copy import\OSFL2007\* "C:\mybackupfolder\OSFL\New" md "C:\mybackupfolder\OSFL\New\export" copy export\OSFL2007\* "C:\mybackupfolder\OSFL\New\export" CScript zip.vbs "C:\mybackupfolder\OSFL\New" "C:\mybackupfolder\OSFL\New.zip" cd "C:\mybackupfolder\OSFL" rename New.zip "%TimeStamp%.zip" rd /q/s New

Use at your own risk!
__________________
OSFL (join us!) CFL
Float likeabutterflysting likeabee.




Last edited by aston217 : 05-14-2015 at 12:00 PM.
aston217 is offline   Reply With Quote