kcw | journal | 2001 << Previous Page | Next Page >>

So that's the current Backup Folder AppleScript. I'm not sure about calling it backup since it's only doing Finder copies and it's intended to be more of a folder synchronization routine. In any case, there is one known issue where if you rename or create a folder to a file that is replaced that folder won't be backed up. Not a common case and something I will fix later.

The script also does not delete files in the destination that are deleted in the source. Naturally, that requires going through the destination hierarchy and checking to see if the corresponding source file exists, so that would be a separate routine. There are other features and enhancements to add, though right now it's perfectly usable for my purposes. Future additions include...

  • Logging. Right now I'm logging to the Script Editor log, if you happen to run the script on Script Editor. I should log to a user specified file.
  • File Deletion. The aforementioned feature to make a real synchronization routine.
  • Aliases. What to do with aliases. If you just Finder copy then then they point to the original file, not the corresponding destination file. I can envision several user options: Copy Alias Blindly, Ignore Alias, Copy Real File, Create Corresponding Alias. The last one would be the hardest to implement.
  • Move or Replace Old Files. Instead of doing a duplicate ... with replacing true I could move the deleted file to another folder or the Trash. Some issues when you delete multiple files with the same name and running out of disk space. But it would fix the folder copy problem for AppleShare volumes.
  • More Filters. Copy only if the destination is older. Filter by file size or other file attributes. Filter by user supplied function (though admittedly this is more of a power user feature).
  • More Configuration. This is a big one. A user interface to specify options. This is beyond current AppleScript, though I could use a lot of simple dialog boxes, which would be quite clumsy. AppleScript Studio is the holy grail of AppleScript programming, due out sometime in the future.
  • Preferences. This goes hand in hand with the previous one. Save and retrieve preferences.

AppleScript is a pretty good scripting language. You can do a fair amount of things, though it depends on application support to get its real power. The one thing I really miss is multithreading support. Script Editor especially you can't do anything while a script is running. But in actual scripts there is no way to really set up multithreading. You can sort of hack it by sending a message to an application and just continuing without waiting for a reply. But that makes multi-tasking a per OS process thing which is quite heavy weight.

It would be really nice, in another half dozen revisions, to submit this to Version Tracker and have other people start using it. I'm only writing this because other Shareware backup programs failed in one way or another with my system setup. Some were reasonably priced if they had worked, some were ok priced but I couldn't test them without buying it, and some are commercial so you can't even look at them without buying them. I want to get out a nice, simple, not great yet free backup program for people like me.

The other choice of language would have been to use a real language of which Java is the only one I really know. Unfortunately, Java is not that great dealing with files. The options would be system calls to do copies, which is not portable; or do the file copy in Java, which doesn't support Mac resource forks in the base classes (I'm sure there are Mac specific extensions that can handle this, but then once again you lose the portability, though you can code it to handle multiple formats).

Really though, I wanted to do it in AppleScript because it's faster than doing it in Java and it's a good way for me to learn AppleScript. The reason it took me a day to write this program is that I made so many little errors or couldn't figure out what AppleScript wanted. This is the experience that I need to learn the quirks of AppleScript.

Copyright (c) 2001 Kevin C. Wong
Page Created: August 20, 2004
Page Last Updated: August 20, 2004