It happens that I take 100s of pictures for an event but have no patience to sort through them in order to select the good ones for publishing. And I am not the type of person who signs up for web services that help with that, either. Instead, I export them in a rather small size and then zip them to someone who has the time to choose the good ones. This week, I got a list of about 200 file names back, in a text file. I wasn’t eager to manually select that many pictures.
So I thought launched Script Debugger and got something working in 15 minutes: It takes the list of file names and finds each picture (or movie) of that name and then exports them all.
Here’s the script, which does this even in two ways: First, it sets up a list of names, then it also loops over a range of fixed numbers, adding them to the same list. Finally, it exports them all to a folder.
Feel free to improve the script, such as to read the names from a text file (one name per line) and letting the user choose the destination folder.
-- a manual list of partial file names (no need to include the extension):
set names to {"IMGP0750", "IMGP0752", "K3__5856", "K3__5842"}
-- add more items by a range of numbers:
repeat with i from 163 to 285
set n to "IMGP0" & i
copy n to the end of names
end repeat
tell application "Photos"
-- collect the items from Photos.app
set pics to {}
repeat with name1 in names
set s to (every media item whose filename contains name1)
repeat with s2 in s
copy s2 to the end of pics
end repeat
end repeat
-- export the items - you will have to adjust the path
export pics to file "Macintosh HD:Exported Pictures:"
end tell