Backup Script Improvements Please
Backup Script Improvements Please
- Subject: Backup Script Improvements Please
- From: Xandra Lee <email@hidden>
- Date: Wed, 24 Oct 2001 10:04:11 -0400
Following is a basic script to backup a file - (which may be backed up
numerous times in one day), it seems 'Much Ado' about nothing (very
wordy) and has some weeknesses (most notably uses mod time as method to
avoid dup names -- which severely limits legnth of orig file names)
--NOTE this script is intended to run from OSA Menu as script (not
applet) -- so property updating is out.
I'm interested in ideas how to simplify (less wordy -- but NOT obtuse)
better renaming routine
(without using meaningless names) while keep intent very obvious for easy
editing.
-- REQUIRED: Date string for OSAX (GTQ) -- relies on DateTime CP settings
--BEWARE will have to alter for Files with long names (since can append
Name with date & time)
--NEEDS - test for Word running
>
----SCRIPT START------
property origFldr : "syd:Microsoft User
Data:WD2001Templates:"
property origName : "Normal" -- filename to be backed up (must be in
origFldr)
--path to Backup Folder:
property bakFldr : "jaz:Running Backups:Office Specials:Word Templates
Bak:"
-->>GENERATE PATHS<<
set origPath to origFldr & origName --full path to file (as string)
set bakDup to bakFldr & origName --full path to dup'd normal BEFORE name
change
tell application "Finder"
-->>generate a new name based on date:<<
set modDate to modification date of file origPath
set theDate to date string for (modDate) ---- DateTime CP dependant
set newName to origName & " " & theDate -->"Normal 10/24/2001"
set destPath to bakFldr & newName -- the planned path to renamed backup
set goAhead to true
--!!! BEWARE!!!This will only work for very short named files
if exists file destPath then
set x to modification date of file destPath
if x = modDate then -- STOP SCRIPT if already done.
display dialog "That file's already been backed up!" buttons
{"Cancel"} default button "Cancel" giving up after 3
set goAhead to false
else
--if more than one backup perday, add time to file name
--(ONLY POSSIBLE since name of file so short)
set modTime to time string for modDate
-- grabmins-sec's & avoid colon character
set t1 to (characters 1 thru 2 of modTime) as string
set t2 to (characters 4 thru 5 of modTime) as string
set modTime to t1 & t2
set newName to newName & " " & modTime
end if
end if
if goAhead is true then
-->>Back up to Alt volume...<<
if not (exists alias bakFldr) then
display dialog "Can't locate" & return & bakFldr & return & "Pleae
edit Script."
else
try
duplicate file origPath to folder bakFldr
set name of file bakDup to newName
on error errMsg
display dialog errMsg
end try
end if
end if
end tell
>
----SCRIPT END------
Thanks,
Alix
Alixandra Leigh
AceDesign
email@hidden
------------------------------------------
Furniture:
><
http://home.rochester.rr.com/alexleighs/furniture/furniture.htm>
Renderings:
><
http://home.rochester.rr.com/alexleighs/interiors/interiors.htm>