Applescript or Perl or other???
Hi Jim. Maybe this can get you started. The script expects the infoFile
to have posix paths ( /volumes/subdir/file.ext ). You could make this
faster by using a regex on the cat command via a pipe to strip out all
the paths leaving just the file names. I am sure that parsing it with
AppleScript's TID's will be slower than a sed pipe.
set infoFile to choose file with prompt "Where is the info file?"
set searchDir to choose folder "Where is the directory to search?"
set outputDir to choose folder "Where should I save any located files?"
(* read the file contents into a list *)
set myhandle to quoted form of POSIX path of infoFile
try
set fileInfo to do shell script "/bin/cat " & myhandle
set pathList to every paragraph of fileInfo
on error
beep (2)
display dialog "An error occurred" with icon stop
return false
end try
(* get file names *)
set OD to AppleScript's text item delimiters
set AppleScript's text item delimiters to "/"
if pathList ‚ {} then
tell application "Finder"
set checkNames to name of files of searchDir
repeat with aPath in pathList
(* isolate the file name from the path *)
set searchFile to last item of text items of aPath
set fileCheck to ¬
(items of searchDir whose name is searchFile)
if fileCheck ‚ {} then ¬
duplicate item 1 of fileCheck to outputDir with replacing
end repeat
end tell
else
beep (2)
display dialog "The info file contained no content!" with icon stop
end if
set AppleScript's text item delimiters to OD
--
Koncept <<
"Contrary to popular belief, the most dangerous animal is not the lion or
tiger or even the elephant. The most dangerous animal is a shark riding
on an elephant, just trampling and eating everything they see." - Jack Handey
|