views:

302

answers:

3

Each camera folder has many thousands of photos, I need to open 20-or so specific files which could be located in any one or more folders, all within one 'root' folder:

Photos

|-- CameraA

|-- CameraB

|-- CameraC

I'd like to paste a CSV of the filenames (eg 6504, 6505, 8902, 4501) into an Applescript (or preferably if Applescript could prompt me for input?), run it, and the files open in Photoshop. It's tedious to search for one file at a time in spotlight!

I've located the scripts to search for a single file, a script to open files in photoshop, but I'm hopeless at arrays and loops, assuming applescript can do this.

A: 

Do you really need it to be an AppleScript specifically? It's easier with shell scripting if you ask me:

for f in 6504 6505 8902 4501; do find . -name "$f" -exec open -a "Photoshop" {} \;; done

Where the numbers are replaced with your desired filenames and "Photoshop" is replaced with the actual name of your Photoshop application on the disk ("Photoshop CS" or whatever).

Chuck
it didn't quite work as is, Photoshop failed to launch, so I used the full path. And also filenames needed a *, but I forgot to mention that, my fault):for f in *0299* *0327* *d_0340*; do find . -name "$f" -exec open -a "/Applications/Adobe Photoshop CS4/Adobe Photoshop CS4.app" {} \;; doneThank you Chuck - appreciate your kind help!
A: 

ok, i've had a tinker and came up with a half-AppleScript half-ShellScript that expands on the above. I welcome any comments :)

this works by prompting for partial filenames (separated with a space), finding the top-most Finder window to get the current folder location (root folder to search from), uses a Shell to add stars to the search queries (partial filenames instead of full), perform find command from 'root' folder that we already have open in Finder. Found files are opened in Photoshop.

tell application "Finder"
try
 activate
 beep 1
 display dialog "Enter your image search:" default answer ""
 set dialogInfo to result
 set imgquery to text returned of dialogInfo

 set frontWin to folder of front window as string
 set frontWinPath to (get POSIX path of frontWin)
 tell application "Terminal"
  activate
  set starredImgQuery to do shell script "echo " & quoted form of imgquery & " | sed 's/ /\\* */g'"
  set starredImgQuery to "*" & starredImgQuery & "*"
  do shell script "cd \"" & frontWinPath & "\";for f in " & starredImgQuery & "; do find . -name \"$f\" -exec open -a \"/Applications/Adobe Photoshop CS4/Adobe Photoshop CS4.app\" {} \\;; done"
 end tell
 tell application "Terminal" to quit
on error error_message
 beep
 display dialog error_message buttons ¬
  {"OK"} default button 1
end try
end tell

shell commands are great!!

A: 

Hmmm, code doesn't work for me now!

Panicked and searched around for a "spotlight boolean search" - and found EasyFind! Freeware by Devon technologies: http://www.devon-technologies.com/products/freeware/index.html

Faster to work with and easier to adapt, and it works for boolean searches as above, find the root folder, and boolean search: 6504 or 6505 or 8902 or 4501

Jammy