Rename New Large Shutterstock Preview Images With ID

Update: Since Shutterstock does not show large previews anymore, this code is kind of obsolete, but probably adaptable for other cases.

Shutterstock recently added larger preview images, that’s great for our daily mockups. Sadly the name of these images when dragged out of Safari are just large.jpg, making it difficult to find it later on the site, More so if you have a script that usually extracts the image’s ID from the filename1. So I had to add this ID in the first place, to be able to use my other scripts later in the process (for example when ordering the images). This post on provided the information on how to extract the download source from a files metadata.

I now use this AppleScript with the great Hazel to automatically rename the new larger files when dragged to my desktop. I’m not sure if the ID will always be the sixth item, but for now it works.

set the_path to POSIX path of theFile
set the_itemfroms to "kMDItemWhereFroms" as Unicode text

set v to (do shell script "mdls -name " & the_itemfroms & space & the_path)

set AppleScript's text item delimiters to {"/"}
set the_id to sixth text item of v

set the_newname to "stock-photo-shutterstock-" & the_id

return {hazelExportTokens:{newname:the_newname}}

I will post an adaption for OS X folder actions some time later.

  1. The small preview images have this ID in their filename when dragged out of the browser. ↩
fab1An @fab1An