An AppleScript to easily backup Uplink save game files

Jun 04, '03 08:45:00AM

Contributed by: athagon

When playing Uplink, it's often helpful to back up one's agent files, since getting caught is irreversible and essentially makes one start over from scratch. If one has backed up one's agent files, however, one has a chance to go back and correct one's mistakes.

I've created an Applescript to automate the backing up, and archiving, of Uplink agent files. One will need to create a directory into which the agent file backups will go (mine is ~/Documents/Agent Backups). Here is the script:

set right_now to do shell script "date | awk '{print $1,$2,$3,$6,$4}'"
do shell script ¬
  "cd ~/Documents/\"Agent Backups\"/ ; tar cvf \"" & ¬
   right_now & ".tar\" *.usr ; gzip \"" & right_now & ".tar\""
-- the next three lines are one long line, but you'll have
-- to manually combine the last two segments, as you can't  
-- put an AppleScript line break in a shell command!
do shell script ¬
   "cp \"/Applications/Games/Uplink 1.0.0/Users/\"*.usr 
    ~/Documents/\"Agent Backups\"/"
launch application "TextEdit"
The script should be entered into Script Editor as four lines, and saved as an application. One will also probably want to put it into one's dock, so that the agent files can be backed up and archived and Uplink can be launched with only one click. Before using the script, one will want to change the backup paths in the "do shell script" commands to match whatever backup architecture one has created. The script does the following:
  1. Archives any currently un-archived backed up agent (.usr) files into a tarball using the current date and time as the filename (this is handy if one needs to revert to an even older version of an agent file).
  2. Backs up one's current agent files.
  3. Starts Uplink.
Be sure to, every so often, delete any unwanted backup archives, since, although the archives are compressed, they still take up some space. Alternately, lines one and two of the Applescript can be commented out to disable backup archiving.

Comments (4)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20030602215940677