Posted on Fri - January 13, 2006 Revised Timefolder backup and restore - UPDATEDI recently learned the OS X version of the
replacing command. Under OS 9, you could copy or duplicate and end the command
"with replacing" which would save a couple of lines to delete the previous file.
Under OS X the command is "replacing yes."
This new version eliminates quite a bit of code, and since the script doesn't have to check to see if the previous files exist, it speeds up the process quite a bit. Here's the new TimeFolder
backup.
tell
application
"Finder"
set
mike
to
0
if
disk "MaCei
HD" exists
then
set
mike
to
"Cei"
say
"mak kay eye mak project files"
end
if
if
disk "Artus
iBook"
exists
then
set
mike
to
"AiB"
say
"artus eye book project files"
end
if
if
mike = 0
then
say
"I am confuzzled. I don't recognize the disks"
end
if
if
process
"Palm Desktop"
exists
then
say
"Palm Desktop is quitting"
tell
application
"Palm Desktop"
quit
end
tell
else
say
"Palm Desktop already safe"
end
if
if
process
"iBlog"
exists
then
say
"Local web logs are quitting"
tell
application
"iBlog"
quit
end
tell
else
say
"Local web logs already safe"
end
if
if
process
"Safari"
exists
then
say
"Safari is quitting"
tell
application
"Safari"
quit
end
tell
else
say
"Safari already safe"
end
if
tell
application
"Finder"
activate
set
MasterPalm
to
0
display
dialog "I need to know which Palm Desktop file is
the most recent."
buttons
{"NeoWayland", "OTHERNAME"} default
button "OTHERNAME"
set
MasterPalm
to
(button
returned
of
result)
end
tell
if
MasterPalm
is
"OTHERNAME"
then
duplicate
"Users:neo:Documents:Palm:Users:OTHERNAME:User Data"
to
folder
"Users:neo:Documents:Palm:Users:NeoWayland"
replacing
yes
end
if
if
MasterPalm
is
"NeoWayland"
then
duplicate
"Users:neo:Documents:Palm:Users:NeoWayland:User Data"
to
folder
"Users:neo:Documents:Palm:Users:OTHERNAME"
replacing
yes
end
if
tell
application
"Finder"
duplicate
"Users:neo:Library:Application Support:iBlog"
to
folder
"Users:Neo:Sites:put in library-application support"
replacing
yes
duplicate
"Users:Neo:Library:Preferences:com.lifli.iBlog.plist"
to
folder
"Users:Neo:sites:put in library-preferences"
replacing
yes
duplicate
"Users:neo:Pictures:webgrfx"
to
folder
"Users:Neo:Sites"
replacing
yes
end
tell
if
the
day
of
(the
current
date) < 10
then
set
dom
to
"0" &
the
day
of
(the
current
date)
else
set
dom
to
the
day
of
(the
current
date)
end
if
if
the
month
of
(the
current
date) =
January
then
set
mnt
to
"Jan"
end
if
if
the
month
of
(the
current
date) =
February
then
set
mnt
to
"Feb"
end
if
if
the
month
of
(the
current
date) =
March
then
set
mnt
to
"Mar"
end
if
if
the
month
of
(the
current
date) =
April
then
set
mnt
to
"Apr"
end
if
if
the
month
of
(the
current
date) =
May
then
set
mnt
to
the
month
of
(the
current
date)
end
if
if
the
month
of
(the
current
date) =
June
then
set
mnt
to
"Jun"
end
if
if
the
month
of
(the
current
date) =
July
then
set
mnt
to
"Jul"
end
if
if
the
month
of
(the
current
date) =
August
then
set
mnt
to
"Aug"
end
if
if
the
month
of
(the
current
date) =
September
then
set
mnt
to
"Sep"
end
if
if
the
month
of
(the
current
date) =
October
then
set
mnt
to
"Oct"
end
if
if
the
month
of
(the
current
date) =
November
then
set
mnt
to
"Nov"
end
if
if
the
month
of
(the
current
date) =
December
then
set
mnt
to
"Dec"
end
if
set
y_r
to
the
year
of
(the
current
date)
set
timestamp
to
the
time
of
(the
current
date)
set
neuname
to
mike &
"=" &
dom &
mnt &
y_r &
"•" & timestamp
make
new
folder
at
folder
"Desktop"
of
folder
"neo"
of
folder
"Users"
of
startup
disk with
properties
{name:neuname}
make
new
folder
at
folder
neuname
of
folder
"Desktop"
of
folder
"neo"
of
folder
"Users"
of
startup
disk with
properties
{name:"xfer"}
duplicate
"Users:neo:Projects"
to
folder
"xfer"
of
folder
neuname
duplicate
"Users:neo:Library:Safari"
to
folder
"xfer"
of
folder
neuname
duplicate
"Users:neo:Library:Scripts"
to
folder
"xfer"
of
folder
neuname
duplicate
"Users:neo:Documents:Palm"
to
folder
"xfer"
of
folder
neuname
duplicate
"Users:Neo:Sites:put in library-application support"
to
folder
"xfer"
of
folder
neuname
duplicate
"Users:Neo:Sites:put in library-preferences"
to
folder
"xfer"
of
folder
neuname
duplicate
"Users:neo:Sites:iBlog"
to
folder
"xfer"
of
folder
neuname
duplicate
"Users:neo:Sites:webgrfx"
to
folder
"xfer"
of
folder
neuname
duplicate
"Users:neo:Sites:neowaylanddotnet"
to
folder
"xfer"
of
folder
neuname
duplicate
"Users:neo:Sites:frame pages"
to
folder
"xfer"
of
folder
neuname
duplicate
folder
"xfer"
of
folder
neuname
to
"Users:neo:Documents:currents"
replacing
yes
tell
application
"Disk Utility"
activate
end
tell
say
"I'm ready to make an image from the folder."
end
tell
And here is the new xfer script. This is quite a bit faster than the old one, in part because the Finder doesn't have to test to see if the old file exists before replacing it and I could combine several calls to the Finder into one call. I modified the dialogue a bit and added a log out, since you have to log out and back in anyway to access the new files. UPDATE - The original script I had posted here had a bug, it tried to replace a script while executing it. The fix is simple, for the script folder, use the previous method of "if exists then delete" and then duplicate the script file into the proper place. The script still flies. tell
application
"Finder"
activate
set
XferState
to
0
if
folder
"Users:neo:Desktop:xfer"
exists
then
display
dialog "Are you sure? This will overwrite your
existing project files and it will log out of this account."
buttons
{"NEVER", "Go for it!"} default
button "NEVER"
set
XferState
to
(button
returned
of
result)
if
XferState
is
"Go for it!"
then
duplicate
folder
"Users:neo:Desktop:xfer:Projects"
to
folder
"Users:neo"
replacing
yes
duplicate
folder
"Users:neo:Desktop:xfer:Safari"
to
folder
"Users:neo:Library"
replacing
yes
duplicate
folder
"Users:neo:Desktop:xfer:Palm"
to
folder
"Users:neo:Documents"
replacing
yes
duplicate
folder
"Users:neo:Desktop:xfer:put in library-application support:iBlog"
to
folder
"Users:neo:Library:Application Support"
replacing
yes
duplicate
file
"Users:neo:Desktop:xfer:put in library-preferences:com.lifli.iBlog.plist"
to
folder
"Users:Neo:Library:Preferences"
replacing
yes
duplicate
folder
"Users:neo:Desktop:xfer:iBlog"
to
folder
"Users:neo:Sites"
replacing
yes
duplicate
folder
"Users:neo:Desktop:xfer:webgrfx"
to
folder
"Users:neo:Pictures"
replacing
yes
duplicate
folder
"Users:neo:Desktop:xfer:neowaylanddotnet"
to
folder
"Users:neo:Sites"
replacing
yes
duplicate
folder
"Users:neo:Desktop:xfer:frame pages"
to
folder
"Users:neo:Sites"
replacing
yes
if
folder
"Users:neo:Library:Scripts"
exists
then
delete
folder
"Users:neo:Library:Scripts"
end
if
duplicate
folder
"Users:neo:Desktop:xfer:Scripts"
to
folder
"Users:neo:Library"
delete
folder
"Users:neo:Desktop:xfer"
say
"All files updated. Now logging out."
tell
application
"System Events"
log
out
end
tell
else
say
"Canceling updates"
end
if
else
say
"Nothing on the desktop to transfer"
end
if
end
tell
|
Hello There
This is my no frills blog to cover all the gadgets and gizmos and technology that makes 21st Century life so exciting. Think of it as a messy set of notes that I keep for myself on all sorts of topics. It's really intended for my personal use, but I will explain sometimes as I go along.
My passion is for Macintosh and other Apple products, but I will use others as needed. If my notes and experiences can help or amuse you, so much the better. Categories
Calendar
Archives
XML/RSS Feed
Neolinks
Homepage AOL Homepage Geocities Homepage Dot Mac Homepage PaganVigil AOL Pagan Vigil Geocities Pagan Vigil Dot Mac Pagan Vigil Technopagan Yearnings AOL Technopagan Yearnings Geocities Technopagan Yearnings Dot Mac Technopagan Yearnings Webmaster NetworkSolutions Dot Mac dotmac.info WhatTheFont MacHighway America Online Yahoo! Geocites ZoneEdit iBlog HaloScan StatCounter Feed to JavaScript Performancing Design Re-Imagineering Steampunk Workshop Design Observer Subtraction Paleo-Future Hardware Apple CDW Cyberguys PCMall X-Treme Geek Software TypeStyler Graphic Converter Palm News & Info Palm Infocenter Brighthand Forums - Palm mytreo.net Making Music Apple - iLife - GarageBand iCompositions Royalty Free Music, Free Sound Effects, Royalty-free Sounds Tune Up Loops Twin Cities MIDI Home Page Andy's OSX Music Page Apple Logic Pro - AUDIO Hints & Tips Library of scanned player piano music rolls Garritan Orchestral Libraries Drums on Demand Bandmateloops Coolness Gizmodo Engadget Daring Fireball RoughlyDrafted Magazine Applefritter iGeek MaKiDo Mac vs. PC Info Why I Hate Microsoft World of Ends Tracking What Is My IP Address? IP Address Trace Geektools WHOIS ARIN WHOIS Database Search Zabra People Search NeoBlogs
Statistics
Total entries in this blog:
Total entries in this category: Published On: Dec 07, 2008 01:28 PM |