Re: File Syncronizing
Re: File Syncronizing
- Subject: Re: File Syncronizing
- From: email@hidden
- Date: Sat, 17 Feb 2001 10:25:18 EST
Thanks Chris for your response. It's gotten me off to a good start, but I'm
still having trouble with a couple aspects (questions at the end of the two
posted scripts). First, here's the original script that does work so you can
see what I want to do. This script works correctly, but is very slow:
-- ---------------------------------------------------------
-- Preprocessed by Convert Script 1.0d2
-- ---------------------------------------------------------
tell application "Finder"
set theCurrentProfiles to (every file of folder "Jupiter:Ken:Profile
Distribution:Profiles")
set theLocalSysFold to system folder as alias
set theLocalSysFold to theLocalSysFold & "ColorSync Profiles:" as text
set theLocalProfiles to (every file of folder theLocalSysFold)
repeat with thisProfile in theLocalProfiles
try
if modification date of thisProfile is not (modification date of
file ("Jupiter:Ken:Profile Distribution:Profiles:" & (name of thisProfile)))
then
delete thisProfile
end if
on error
delete thisProfile
end try
end repeat
set profilesToAdd to {}
repeat with thisProfile in theCurrentProfiles
if not (exists file (theLocalSysFold & (name of thisProfile))) then
set profilesToAdd to profilesToAdd & thisProfile
end if
end repeat
duplicate profilesToAdd to system folder
end tell
-- ---------------------------------------------------------
Next, here is what I have done so far with Chris's suggestions:
-- ---------------------------------------------------------
-- Preprocessed by Convert Script 1.0d2
-- ---------------------------------------------------------
tell application "Finder"
set colorsyncProfiles to "" & (path to system folder) & "ColorSync
Profiles:"
set masterProfiles to (every file of folder "Jupiter:Ken:Profile
Distribution:Profiles")
set {nameMaster, modificationDateMaster} to {name, modification date} of
every file of folder "Jupiter:Ken:Profile Distribution:Profiles"
set theLocalProfiles to (every file of folder colorsyncProfiles)
set {nameLocal, modificationDateLocal} to {name, modification date} of
every file of folder colorsyncProfiles
if nameMaster = nameLocal then
if modificationDateMaster = modificationDateLocal then
-- How do I exit the script here? I can't seem to find it or
remember
else
my compareByItem(masterProfiles, nameMaster,
modificationDateMaster, theLocalProfiles, nameLocal, modificationDateLocal)
end if
else
my compareByItem(masterProfiles, nameMaster, modificationDateMaster,
theLocalProfiles, nameLocal, modificationDateLocal)
end if
end tell
on compareByItem(masterProfiles, nameMaster, modificationDateMaster,
theLocalProfiles, nameLocal, modificationDateLocal)
tell application "Finder"
repeat with i from 1 to (count of theLocalProfiles)
if (item i of nameLocal) is not (item i of nameMaster) then
delete (item i of theLocalProfiles)
end if
end repeat
set profilesToAdd to {}
repeat with thisProfile in masterProfiles
if not (exists file (colorsyncProfiles & (name of thisProfile)))
then
set profilesToAdd to profilesToAdd & thisProfile
end if
end repeat
duplicate profilesToAdd to system folder
end tell
end compareByItem
-- ---------------------------------------------------------
Okay, so here are my questions:
1) How do I terminate a script when the two lists match?
2) The line "if nameMaster = nameLocal then" does not evalute true even when
the same files are in both folders. What am I missing?
3) In the compareByItem handler, I cannot use item i of nameLocal and test
that with item i of nameMaster, because if there is a discrepancy, then the
positions in the lists simply won't match. How would I now go about testing
the lists once I have the information in variables? I'm not sure why, but I
just have a real mental block on this task at the moment.
Thanks for any help that anyone can give!
Ken Fleisher
email@hidden
p.s. R23 is no longer the only one to use his script to post code here! (Woo
Hoo!)