Backup Multiple folders in a list....

I’m writing a script to backup some folders to my iPod.

I’m backing up several folders and instead of listing each folder and the command, I like to have a list of folders at the start of the script and have the command repeat for each folder.

Here’s what I’m currently doing:

set this_iPod to "iDonut:" -- Remove from real script

(* Backup  *)

set BackupFolder to "Backup:"
set HOmeBackupFolder to "Home Backup"
set MyLocation to this_iPod & BackupFolder & HOmeBackupFolder as string
try
	get MyLocation as alias
on error
	tell application "Finder"
		make new folder at this_iPod & BackupFolder with properties {name:HOmeBackupFolder}
	end tell
end try

(* Sparseimage to Backup *)

set SourceFolder to (path to home folder as string) & "Documents:Area 52.sparseimage"

do shell script ("rsync -aE --delete-after " & (quoted form of POSIX path of SourceFolder & space & quoted form of POSIX path of MyLocation)) & " || echo -n"

(* My Stuff to Backup *)

set SourceFolder to (path to home folder as string) & "Documents:My Stuff"

do shell script ("rsync -aE --delete-after " & (quoted form of POSIX path of SourceFolder & space & quoted form of POSIX path of MyLocation)) & " || echo -n"

(* Web Receipts to Backup *)

set SourceFolder to (path to home folder as string) & "Documents:Web Receipts"

do shell script ("rsync -aE --delete-after " & (quoted form of POSIX path of SourceFolder & space & quoted form of POSIX path of MyLocation)) & " || echo -n"

(* Delicious Library to Backup *)

set SourceFolder to (path to home folder as string) & "Library:Application Support:Delicious Library"

do shell script ("rsync -aE --delete-after " & (quoted form of POSIX path of SourceFolder & space & quoted form of POSIX path of MyLocation)) & " || echo -n"

(* Sounds to Backup *)

set SourceFolder to (path to home folder as string) & "Library:Sounds"

do shell script ("rsync -aE --delete-after " & (quoted form of POSIX path of SourceFolder & space & quoted form of POSIX path of MyLocation)) & " || echo -n"

Ideally I’d like to just list the locations:

Set DeliciousLibrary to (path to home folder as string) & "Library:Application Support:Delicious Library"
set SoundsFolder to (path to home folder as string) & "Library:Sounds"

Then run the rsync command.

Can anyone point me in the right direction?

Model: iMac
AppleScript: 2.1.1
Browser: Safari 523.12.2
Operating System: Mac OS X (10.5)

Hi,

try this:


set this_iPod to "iDonut:" -- Remove from real script

set documentFolder to POSIX path of (path to documents folder)
set UserAppSupportFolder to POSIX path of (path to application support folder from user domain)
set UserLibraryFolder to POSIX path of (path to library folder from user domain)
set FolderList to {documentFolder & "Area 52.sparseimage", documentFolder & "MyStuff", documentFolder & "Web Receipts", UserAppSupportFolder & "Delicious Library", UserLibraryFolder & "Sounds"}
(* Backup  *)

set BackupFolder to "Backup:"
set HOmeBackupFolder to "Home Backup"

set MyLocation to this_iPod & BackupFolder & HOmeBackupFolder as string
try
	get MyLocation as alias
on error
	tell application "Finder"
		make new folder at this_iPod & BackupFolder with properties {name:HOmeBackupFolder}
	end tell
end try

(* FolderList to Backup *)
repeat with oneFolder in FolderList
	do shell script "rsync -aE --delete-after " & quoted form of oneFolder & space & quoted form of POSIX path of MyLocation & " || echo -n"
end repeat

Thanks StefanK for all your help.

I’ve now got 2 scripts I use to backup/sync My work Mac to my Home mac via my iPod.

Thanks
nvp