Economy-x-Talk - Sample Scripts
BackUp AS
"Here's my script of Backup (for OS pre-X only) in his English dialogs
version." by Roberto Minotti.
Save this scripts as a droplet. Drop a destination partition or volume onto the droplet, then drop the folder you want to backup onto the droplet. This script has been slightly adjusted. The variable "backup" cannot be used in AS 1.8.3 and has been replaced by the variable "backp". Note that the quit handlers and commands have been commented out. You need to remove the dashes if you want to create a droplet. The idle handler has been commented out, too. [MS]
property orig : ""
property dest : ""
property nomdos : ""
property backp : "Backup"
property rep : ""
property essai : ""
on open LaListe
set {orig2, dest2, nmedest2} to {"", "", ""}
repeat with x in LaListe
set x to x as text
if (the last character of x) is ":" then
set AppleScript's text item delimiters to {""}
set x to (characters 1 thru -2 of x) as text
set AppleScript's text item delimiters to {":"}
set nomdos3 to the last text item of x
set x to every text item of x
set qt to the number of items of x
set x to x as text
set AppleScript's text item delimiters to {""}
if (qt is 1) and (dest2 is "") then
set dest2 to x
end if
if (qt is greater than 1) and (orig2 is "") then
set orig2 to x
set nomdos2 to nomdos3
end if
end if
end repeat
if orig2 is not "" then
display dialog "The folder to backup is \"" & orig2 & ¬
"\"." with icon note
set orig to orig2
set nomdos to nomdos2
end if
if dest2 is not "" then
display dialog "New destination is \"" & dest2 & ¬
"\"." with icon note
set dest to dest2
tell application "Finder" to ¬
if not (exists folder backp of disk dest) then ¬
make new folder at disk dest with properties {name:backup}
end if
-- tell me to quit
end open
--on quit
-- continue quit
--end quit
on run
set cestbon to true
set cestbon to cestbon and (dest is not "")
set cestbon to cestbon and (orig is not "")
tell application "Finder" to set cestbon to ¬
cestbon and (exists folder orig)
tell application "Finder" to set cestbon to ¬
cestbon and (exists disk dest)
if not cestbon then
tell me to activate
beep
display dialog "Drag'n Drop on me a destination partition " & ¬
"then the folder icon you want to backup to fix the backup." buttons ¬
{"OK"} default button 1 with icon stop
set rep to ""
return
end if
tell application "Finder" to if not ¬
(exists folder backp of disk dest) then ¬
make new folder at disk dest with properties {name:backup}
set rep to the button returned of ¬
(display dialog "Do the backup ?" buttons ¬
{" Cancel ", "OK"} default button {"OK"} with icon note)
set quoifaire to "LetsGo"
if quoifaire = "LetsGo" then my dobackup()
end run
--on idle
if rep is "OK" then
tell application "Finder" to ¬
if exists folder nomdos of folder backp of disk dest then ¬
set rep to ""
return 1
else
tell me to quit
end if
--end idle
on dobackup()
set i to 1
tell application "Finder" to repeat while exists folder nomdos ¬
of folder backp of disk dest
set essai to nomdos & "#" & (i as text)
try
set name of folder nomdos of folder backp of disk dest to essai
on error
set i to i + 1
end try
end repeat
if (count of essai) > 31 then
set longueur to count of ("#" & i)
set essai to text 1 thru (31 - longueur) of essai
set essai to (essai & "#" & i) as text
end if
tell application "Finder" to with timeout of 3600 seconds
activate
copy folder orig to folder backp of disk dest
end timeout
end dobackup
Keep this extensive resource of tutorials and samples on-line! Support RunRev.info!
| Yes, this script is useful. I make a donation and choose freely how much I want to donate on-line (PayPal). Click here if you want to make a donation in dollars. | This script has not (completely) solved my problem and I want Economy-x-Talk to take care of it. Let me contact you. |
Copyright©2002-2008 by Mark Schonewille, Nijmegen, the Netherlands. This web site is in no way affiliated with Runtime Revolution Ltd., but we do recommend the Revolution development platform.