Settings backup script
Settings backup script
- Subject: Settings backup script
- From: "Joseph A. Weaks" <email@hidden>
- Date: Thu, 2 Aug 2001 03:57:15 -0500
Well, here it is... my first real script. I've been lurking on the
list for over a month. If it pleases you, feel free to peruse the
script and let me know what I did needlessly, incorrect, foolishly,
etc.
The script backs up the settings file created by an app into a unique
folder so that the app can be run again to create a new settings
file. The goal is to accumulate several settings files in order to
launch using different preference configurations.
I thought the use of the comments field was pretty clever.
-- Accordance settings backup script
-- This script will take the settings file currently in use, and
create a backup of it in a folder with a descriptive name.
-- The default file backed up is the "Highlight settings file". This
may be changed by altering the SettingsFile variable just a few lines
below.
-- Written for Accordance 5.
tell application "Finder"
-- Defining the path to the Accordance folder and the
settings file to be backed up
set AccordanceFolder to folder "Accordance folder" of folder
"Applications" of startup disk as string
set SettingsFile to item "Highlight settings" of folder
"Accordance Settings " of folder AccordanceFolder as string
-- Reads the Comments info field of the settings file
try
set MyComments to the comment of item SettingsFile
on error
set MyReply to choose folder with prompt "Please
locate the Accordance folder. To avoid this step in the future,
please edit the AccordanceFolder variable at the beginning of this
script. It's very easy to do, so give it a try."
set AccordanceFolder to MyReply as string
end try
-- Ask for a Comment entry if none is found
if MyComments is "" then
set MyReply to display dialog "Please add a
descriptive comment to the current settings file. A folder with this
name will be created in a Backup folder inside the Accordance folder
to house this version of the settings file." default answer "Replies
over 30 characters will be truncated."
if (button returned of MyReply is "OK") then
set MyComments to text returned of MyReply
end if
set comment of item SettingsFile to MyComments
end if
if the number of characters of the MyComments is greater than 30 then
set the MyComments to (characters 1 thru 30 of the
MyComments) as string
end if
-- Checks to see if an "Accordance Backups" folder exists
exists folder "Accordance Backups" of folder AccordanceFolder
if result is false then
make new folder at folder AccordanceFolder with
properties {name:"Accordance Backups"}
end if
-- Checks to see if a folder name with this Comment exists
exists folder MyComments of folder "Accordance Backups" of
folder AccordanceFolder
if result is false then
make new folder at folder "Accordance Backups" of
folder AccordanceFolder with properties {name:MyComments}
end if
-- Moves a copy of the current settings file into the backup folder
duplicate item SettingsFile to folder MyComments of folder
"Accordance Backups" of folder AccordanceFolder with replacing
end tell
Joe Weaks
--
*****************************************
Rev. Joseph A. Weaks
Pastor, Bethany Christian Church, Dallas
Ph.D. Student, Brite Divinity School
email@hidden
http://stuwww.tcu.edu/~jweaks/
*****************************************