Hi again
I’m almost there now. Here’s what I’ve got…and it works! The only thing is that I’d like to add the suffix “-COPY” and date (ie so the folder would be called “Documents-COPY 09/04/06” to the end of each file in the targetFolder. Any idea how to do this easily? I tried a few things, none of which worked out.
tell (current date) to tell 100000000 + day * 1000000 + (its month) * 10000 + year as string ¬
to set targetFolder to "BackupTest-" & text 2 thru 3 & "/" & text 4 thru 5 & "/" & text -4 thru -1
set backupfolder to "Backup:Scripted Backups:"
--the block belows lists the files to be copied
property filesToCopy : {alias "SystemX:Users:Matt:Documents:", alias "SystemX:Users:Matt:Library:StickiesDatabase", alias "SystemX:Users:Matt:Library:Safari:", alias "SystemX:Users:Matt:Desktop:"}
--the block below lists the files that aren't to be copied. The defining of doNotCopyFilesA and doNotCopyFilesB is necessary as because the source location of files/folder is different, they must be returned to different places.
set doNotCopySourceA to "SystemX:Users:Matt:Documents:General:Miscellaneous:Photoshop_Notes:"
set doNotCopySourceB to "SystemX:Users:Matt:Documents:Palm:Users:Matthew Adams:Backups:"
--the block below lists the files which AREN'T to be copied.
property doNotCopyFilesA : {alias "SystemX:Users:Matt:Documents:General:Miscellaneous:Photoshop_Notes:Archives:"}
property doNotCopyFilesB : {alias "SystemX:Users:Matt:Documents:Palm:Users:Matthew Adams:Backups:TT3Update.prc", alias "SystemX:Users:Matt:Documents:Palm:Users:Matthew Adams:Backups:English Dictionary (XLarge).pdb", alias "SystemX:Users:Matt:Documents:Palm:Users:Matthew Adams:Backups:WE 2003 Maps HiRes.prc", alias "SystemX:Users:Matt:Documents:Palm:Users:Matthew Adams:Backups:WE 2003 Info.pdb"}
set tempStorageFolderA to "SystemX:Applications:Temporary Storage:A:"
set tempStorageFolderB to "SystemX:Applications:Temporary Storage:B:"
--the block below checks to see if the backup has already been perform. If not, a backup folder (with date attached) is created adn the script proceeds to move and copy files. If the backup has already been run, a dialog will give the option to cancel (ie stop the script) or delete the existing backup folder and create a new one.
tell application "Finder" to tell folder backupfolder
tell folder targetFolder to if exists then
tell me to display dialog "The backup for today has already been actioned. Backing up again will overwrite files. " & ¬
"Continue anyway?" default button 1
delete
end if
--the block below moves the files that aren't to be copied into a temporary storage location
make new folder at it with properties {name:targetFolder}
move every item of doNotCopyFilesA to tempStorageFolderA
move every item of doNotCopyFilesB to tempStorageFolderB
--the line below actually performs the copying of files listed in filesToCopy to targetFolder
duplicate every item of filesToCopy to folder targetFolder --performs copying of files defined in filesToCopy line, to targetFolder
--the block below moves the files that weren't copied from their temporary storage location, back to their respective original folders.
move every item of doNotCopyFilesA to doNotCopySourceA -- Moves DoNotCopyFilesA back to doNotCopySourceA
move every item of doNotCopyFilesB to doNotCopySourceB -- Moves DoNotCopyFilesB back to doNotCopySourceB
end tell
POSSIBLE IMPROVEMENTS:
I have a feeling that I could remove these two lines:
set tempStorageFolderA to "SystemX:Applications:Temporary Storage:A:"
set tempStorageFolderB to "SystemX:Applications:Temporary Storage:B:"
and have all files that aren’t to be copied dumped into one folder - however that’s just a small improvement. Or would this prevent them from being sorted back into their original folders…?
I tried to make this part cleaner:
property doNotCopyFilesA : {alias "SystemX:Users:Matt:Documents:General:Miscellaneous:Photoshop_Notes:"}
by doing something like :
property doNotCopyFilesA : {alias "Photoshop_Notes:" of doNotCopySourceA}
But it wouldn’t work. If this could be done, it would clean up alot the jumble associated with doNotCopyFilesB as there are many long path names listed.
One last thing - how could I make the dialog clearer? My idea would be to have two buttons : “Continue & overwrite” and “Cancel & exit” . The latter would be the default button and would cause the script to stop in its tracks.
Once again, thanks for all the help.
Matthew
PS - sorry for not inserting by scripts as compiled scripts before. I didn’t know how to do it.