AppleScript/Script Editor Help!!!

Joined
Aug 16, 2006
Messages
7
Reaction score
0
Points
1
I'm trying to create my own form of a backup program through script editor. I downloaded the backup program from .Mac and I'm not too much of a fan of how it works. I would like to be able to run a script that will copy everything from my movies folder to my external hard drive.

Can anyone help??
 
Joined
Oct 7, 2005
Messages
346
Reaction score
14
Points
18
Location
Seattle
Your Mac's Specs
MBP CD 1.83/2ghz/7200 100g + Mini 2ghz C2D 2gb + Mini 1.42ghz G4 + PM 7200/120 + Newton OMP
This would probably be much easier (and faster) with a Unix command...

Code:
tar cf - ~/Movies | (cd /Volumes/External\ Hard\ Drive/backup_dir ; tar xf -)

This will recursively take everything in your movies directory and copy it to the external hard drive named "External Hard Drive" into a directory called backup_dir.

It's a very stupid script though -- it will copy files that have already been copied and overwrite what's already there. It could (fairly) easily be rewritten to check for existing files.

Also check the manpage for the rsync command. It supports backing up locally (as well as to remote systems) and may prevent duplicating your efforts as in the above script. Either way, you can schedule these jobs to run via cron.
 
Joined
Mar 11, 2004
Messages
1,964
Reaction score
174
Points
63
This AppleScript isn't intelligent, either, because it, too, would copy all the movies it already copied.

The script assumes that "Jeff" is your login name, that the Movies backup folder is called "Movies Backup" and that it exists in the pathway created here for the purposes of the script.

It starts with if/then so that if the backup Movies folder doesn't exist or was deleted, the script wouldn't stall if it couldn't delete the first backup to allow the second one with the same name to duplicate. You'd save it as an application.

tell application "Finder"
if folder "Movies" of folder "Movies Backup" of folder "Jeff" of folder "Users" of disk "External" exists then
delete folder "Movies" of folder "Movies Backup" of folder "Jeff" of folder "Users" of disk "External"
end if
duplicate folder "Movies" of folder "Jeff" of folder "Users" of startup disk to folder "Movies Backup" of folder "Jeff" of folder "Users" of disk "External"
end tell
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top