New here
I searched the forums, but couldn’t find what I need.
Please move if this isn’t the right forum, thanks.
I’m trying out applescript by making a small backup thingy.
This script backs up files to my Documents folder in an organized way.
Next I’m making a seperate script to copy that backup folder from Documents to my iPod when I connect it.
I would like to call the backup script before copying to my iPod, in order to get the latest files.
I might change the backup script to backup more or different files over time.
When I execute the script to copy my backup to my iPod, I want it to execute the backup script first.
So I figure need to do something like: do applescript “path:to:backup:script.scpt”
Sounds like a bug in your backup script which I assume uses Finder to perform its various tasks.
The AppleScript language defines a number of built-in types for identifying both existing and new files, folders and disks within your Mac’s filesystem. (Not to be confused with any filesystem-related classes and objects defined in individual scriptable applications such as Finder and System Events.) alias “some mac path” defines an object of type alias, used to identify an existing file, folder or disk.
I changed things around a bit, so I’ll only need 1 script.
It tries to zip the folder to the iPod if attached.
Nice to know how to run another script for future work though
I know a bit of Perl and decided that I would be able to use Applescript without too much specific education.
I would greatly appreciate if you could look at it to see if I got the hang of things, or need to get a tutorial.
It works, but I’m not overly sure if it’s the proper way to handle things.
tell application "Finder"
-- list of files to back up
-- backup Safari bookmarks & form values
duplicate file "Library:Safari:Bookmarks.plist" of home to folder "Documents:Backup:Safari" of home with replacing
duplicate file "Library:Safari:Form Values" of home to folder "Documents:Backup:Safari" of home with replacing
-- backup iTunes library files
duplicate file "Music:iTunes:iTunes 4 Music Library" of home to folder "Documents:Backup:iTunes" of home with replacing
duplicate file "Music:iTunes:iTunes Music Library.xml" of home to folder "Documents:Backup:iTunes" of home with replacing
-- delete older Mail backup
if folder "Documents:Backup:Mail" of home exists then
delete folder "Documents:Backup:Mail" of home
end if
-- backup mailboxes
duplicate folder "Library:Mail" of home to folder "Documents:Backup" of home
--
-- check if iPod is connected
if file "Backup.zip" of disk "Toto" exists then
delete file "Backup.zip" of disk "Toto"
empty trash
end if
-- zip to iPod
try
do shell script ("/usr/bin/ditto -c -k -rsrc --keepParent ~/Documents/Backup /Volumes/Toto/Backup.zip")
end try
end tell
BTW for other people viewing this script:
note that it will empty the trash, you might not want to do that if you keep stuff in the trash, which I never understood, but anyway