Re: comparing two lists, one of which is very big and remote?
Re: comparing two lists, one of which is very big and remote?
- Subject: Re: comparing two lists, one of which is very big and remote?
- From: David Simerly <email@hidden>
- Date: Mon, 10 Sep 2001 14:19:43 -0700
- Url: http://www.digital-native.com
on 9/10/01 10:23 AM, Bill Christens-Barry at <email@hidden> wrote:
>
I have the following task: Check a list of the names of about 20
>
files on a local (Mac) drive against the names of files (as many as
>
100,000 in a single unstructured directory ?!) on a remote,
>
Windows-hosted volume.
>
....
>
What efficient techniques are available for doing this? Any concrete examples?
Here's something that might help (watch out for e-mail line breaks):
------- begin example
-- build a simple test list
set find_list to {"System", ".app", ".pdf", "Finder"}
-- tell Finder what to do
tell application "Finder"
-- get a list containing every first-level folder on the startup disk
set the_folders to (every folder of startup disk)
-- operate on every folder in the folder list
repeat with a_folder in the_folders
-- now iterate through the list of names to find
repeat with find_this in find_list
-- list files containing the current string
set got_any to (every file of a_folder whose name contains
find_this)
-- check to see whether we got a hit
if got_any is not {} then
-- if we got a hit, then process that file further
my processFurther(find_this, a_folder, got_any)
end if
end repeat
end repeat
end tell
on processFurther(find_this, a_folder, got_any)
-- make an empty list
set proc_list to {}
-- fill it with the found stuff
repeat with a_name in got_any
set end of proc_list to (a_folder as text) & a_name
end repeat
-- display the list
beep
choose from list proc_list with prompt "Found the following \"" &
find_this & "\" files:" default items {1}
end processFurther
-------- end example
The limitation of the above code is that it goes only into the first level
of the folder hierarchy. So while it will find the file "Finder" at
HD:System Folder:, it won't find "Finder.palette" at HD:System
Folder:Preferences:OneClick:Palettes:. And of course, this script would be a
whole lot simpler if one could just write:
tell app "Finder" to set the_list to every file of startup disk whose name
is "foo"
But a long-standing bug/deficiency in the Finder's dictionary prevents this.
HTH.
DS
______________________________________
Digital Native
Your guide through the virtual jungle.
______________________________________
Ever Wonder: Why is the time of day with the slowest traffic called rush
hour?