Synchronize Folder Kevin C. Wong -- 20011107 -- v 1.0b6 Synchronize destination folder to match source folder.
20011107 1.0b6 -- Now requires Mac OS X 10.1 which has many AppleScript fixes and enhancements. -- Don't use "info for" since 10.1 fixed the problems "info for" worked around. -- Removed copy invisible option because you need to get it from properties which also returns file size. -- Removed addIsFolderAttribute() because we don't use it anymore. -- Verbose logging of copy decisions. -- Use sort of depth-first folder traversal instead of level-order folder traversal. -- Do sync delete for each folder right after sync copy of folder. -- Choose file name now returns <>. Change to check for m_log_file is not boolean. -- Use creation date instead of modification date for Apps, since mod date is not preserved by Finder copy. -- Finer logging control: choose from list of five attributes to log.
20011028 1.0b5 -- Add: m_diff_sec so that modification dates can differ by a few seconds. Default to 60. -- Add: m_filter_files so that certain files can be skipped. Default to system files. -- Add: m_copy_invisible so that invisible files can be skipped. Default to false. -- Add: m_verbose_logging prints every file being checked. -- Bug: Trying to copy folder items if destination folder wasn't created because file name is illegal. -- Add: m_error_logging for suppressing error and filter logging.
20011026 1.0b4 -- Use "list folder" instead of "get items of folder alias". Then use file specifications instead of actual files, use "info for " to get most if item info we need. These changes work with applications and invisible items, which didn't work with "get items of folder alias". Lots of little changes to support the new mechanism.
20011025 1.0b3 -- Bug: No date by comparison if m_copy_newer_files_only is false -- Fix: Delete or move non-folder file before we create folder to replace it. -- Fix: Close m_log_file when done. -- Fix: Close m_log_file before opening it again in case it's already open. -- Fix: Test for log write should be "class of m_log_file is file specification". -- Fix: Start writing to log file at the end of the file, not the beginning. -- Fix: Added line endings to log output. -- Workaround: Skip Application files.
This is the latest version of my Synchronize Folder AppleScript (not
Folders
because it only does it one-way). Beta 5 added filters so it wouldn't
try to
copy every file, especially weird Finder files that are irrelevant. It
also
added some logging options so I could see each file being checked,
which
made me realize that Beta 4's "info for" usage is very slow because it
returns the folder size. If you have a couple thousand files in a
folder,
over a network share it does take a long time to calculate it. My first
thought was to use the old "get item" method and do a fallback to "info
for"
for Applications and a couple of other file types that failed.
Luckily, I waited until Beta 6 and Mac OS X 10.1 to implement that. Mac
OS X
10.1 fixes a bunch of things, such as you can now "get item" and
retrieve an
Application and get attributes from it without erroring. Unfortunately,
a
bunch of other things broke (e.g. "choose file name" now returns an
actual
file instead of a file specification) which I spent some time fixing.
The
upshot of which is that Beta 6 and onwards no longer supports Mac OS X
10.0.
Beta 6 goes back to the Beta 3 roots, using "get item" instead of "info
for",
which is much faster since I don't need to know file sizes. I still use
"list
folder" because that returns invisible files and file extensions that
the
Finder filters out occasionally. I also added more log settings because
some
settings are only really useful if you're running the script with
Script
Editor and have the Event Log open. This way I can just output the info
that
I want -- I think that Event Log crashes Script Editor if it gets too
long,
though I thought those memory limitations were removed in Mac OS X.
One big change was to make folder traversal depth-first instead of
level
order. Depth first means that if you quit the script in the middle of
its
run, you can restart from the last folder it was working on, knowing
that
previous folders are sync-ed up correctly (note that you don't have the
ability to choose certain folders to copy, yet). With level order if
you
stop in the middle, every subfolder is sync-ed up a little so you have
to
start all over. Depth first order also requires doing the delete sync
portion
per folder, as soon as each folder is done. The bonus is that we
eliminate
the duplicate folder traversal code so the code is not as large as it
could
have been.
I still haven't done a big test with Beta 6 -- I'll do that tonight. So
there
may be a few errors will I will fix in Beta 7. Beta 7 will also include
other
minor code changes to take care of some weird files that seem to be
copied
every time I run the AppleScript, even though the files haven't changed
(or
at least I don't think they've changed). That leaves Beta 8 for feature
enhancements: create a Deleted Items hierarchy so that if you choose
the
move option, the files are preserved in context; also save the current
settings in properties so that you don't have to reinput them
constantly,
maybe tie it in to an auto-run option that doesn't ask for user input.
|