scripting a find
scripting a find
- Subject: scripting a find
- From: Brian Mather <email@hidden>
- Date: Thu, 31 May 2001 12:29:48 -0400
I'm stumped and would love some guidance. I've already completed this
project manually making some of this moot, but face it so often that a more
automated solution would be prudent, I believe.
Here's my project and my goals:
I have a text (tab delimited) file listing a number of files I want to find
on a mounted network volume, copy to a local machine and then delete from
the network volume. When searching for each file the result will be several
files found (some jpeg, some gif and 1 psd file). I'd like to evaluate the
results and copy the psd file to my local machine and then delete every
occurrence of the file from the network volume.
I've found at Macscripter,net several threads describing how to complete, or
at least attempt searches using sherlock, and detailing the need to index a
volume in order for it to work properly. Unfortunately, I've so far been
unable to index the mounted volume enabling this approach and frankly am not
optimistic I'll be able to do this. Are there any alternative approaches I
should consider?
Here are the beginnings of a script. As you'll no doubt see I've not yet
added the evaluation process and the subsequent copy and/or delete steps,
not have I figured out how to tell sherlock which volume to search.
Any advice gladly accepted.
---begin script
set file_ref to open for access file "Macintosh HD:Desktop folder:blah"
set the_text to read file_ref
close access file_ref
set oldDelimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to return
set all_my_text to every text item of the_text
set AppleScript's text item delimiters to oldDelimiters
set my_text to {}
repeat with x from 1 to ((length of all_my_text))
set my_text to my_text & {word 1 of item x of all_my_text}
end repeat
repeat with i in my_text
tell application "Sherlock 2"
activate
search for i -- with display
-- how do I indicate which volume to search?
-- evaluate, copy and delete: no idea of the syntax...
end tell
end repeat
Brian Mather
Digital Photographer
Global Sports Interactive
610-491-7091
http://www.globalsports.com