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

Beta 9 is one of the better versions of my Synchronize Folder AppleScript. I've greatly cut down the number of spurious copies and it seems to work well with all of my files (including a bunch of weird files in Mac OS X's ~/Library folder). There are still a couple of issues which I will go into later, but right now it's functional enough that I don't expect it to fail when I run it.

The three beta versions after Beta 6 I've concentrated on solidifying the existing feature set. Several bugs fixed involving Unicode text. Strangely enough, Unicode text output is different than ASCII, so when I do a text search with BBEdit, it skips the Unicode text. Unless I copy and past the Unicode text into the Find box, in which case it then skips ASCII text. Sigh. Unfortunately it has to be this way because Mac OS X can have Unicode text in file names.

Two big fixes. The first is to copy the modification date from the source to the destination, after the source is copied to the destination. This solves the "destination modification date is off by a couple of seconds" problem that I had fixed before my supplying an m_diff_sec variable to provide fudge. Exact modification dates are much better.

But that still left the bug where the destination time can be off by a few time zones. Probably doesn't happen if the destination is on the same computer as the source. But I do backups to another server so I do see that some files are off by an exact hour or two. Many files are not though, which it makes it very confusing to fix.

Actually what I did is not really a fix, but a good workaround. Now you can ignore time differences that are off by exact hours. This eliminates the time zone bug. The drawback is that for changed files, there is an approximately one in 3600 chance that the dates will be off by an exact hour so the files look the same. Now I could also compare file size, but I have hesitated from doing that because file sizes can change depending on the file system. I will implement comparing file sizes and test to see how that works out.

I added an option to ignore files with long names, for the case like mine where you back up from Mac OS X to a Mac OS 9 volume. HFS+ can handle long file names but neither the Mac OS 9 Finder nor Mac OS 9 AppleShare handle long file names. So might as well just filter those files out rather than trying to copy and getting spurious errors. I'm still getting -8082 errors for some files and I haven't yet figured out what that means.

I'm having a big problem with Aliases. The modification date of Aliases change almost randomly it seems. X-Assist definitely seems to change alias mod dates. But if I use creation dates then when you reassign an alias it won't register as a change. Of course, even if I'm copying an alias, it still points to the original file rather than it's corresponding copy. But that's for later.

The AppleScript code is now more than 32kB, too big for Script Editor. That leaves with me with two choices. Split up the script into two or more smaller scripts, which is very object oriented and makes sense. But that would require some rearchitecting since the data has to be shared so that'd a separate data object. The easier option is to use another AppleScript editor.

So I'm currently using Smile, version 2.3. Other than handling bigger files, the only other major enhancement is Find and Replace, which Script Editor has none of. Unfortunately, it also has several annoying shortcomings. It does everything by pixels, so it doesn't change tabs and window borders/wrap based on font size. Annoying is that Page Up, Page Down, Home and End keys don't work, so you have to move around using the scrollbar. Most annoying though is that it doesn't show you the line where an error occurs, so you have to somehow guess that a particular error message came from a particular line. I'm still waiting for AppleScript Studio to come out. Apple released it to developers who receive Dev Tools CD (i.e. paying developers). That I expect to be pretty good and you can create real applications with it.

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