I'm probably making a simple error but I can't seem to get my code to work properly. Figure I'd ask the geniuses on this site for help. I'm a novice scripter, more like code piecer. This is my first post, please be gentle.
What I'm trying to do... I have a folder (and subfolders) full of images. I'd like to have a applescript droplet that I can drag this folder on this droplet to get a text file report of the resolution and path of that image. This way I can insure my files are all the same and correct resolution prior to sending to my end vendor. And if the file isn't the correct resolution, I have the path to which file needs to be adjusted. I was able to create a droplet that could handle individual files, but once I drag a folder of images and sub-folders, I just get a blank text document.
This is what my initial results look like in a text file for files:
72.0 dpi /Users/chewbacca/Desktop/untitled folder/pixels-300x232 copy 2.png
72.0 dpi /Users/chewbacca/Desktop/untitled folder/pixels-300x232 copy 3.png
72.0 dpi /Users/chewbacca/Desktop/untitled folder/pixels-300x232 copy 4.png
Here's my attempt at getting the folder/sub-folder droplet to work:
on open (rawList)
set outFile to (choose file name with prompt "Output file:" default name "ResolutionReport.txt")
open for access outFile with write permission
set fileList to every file of rawList
repeat with i from 1 to number of items in fileList
tell application "Image Events"
launch
set thisImage to open file (oneFile as string)
copy the resolution of thisImage to {H_res, V_res}
close thisImage
end tell
write (H_res as string) & " dpi " & (POSIX path of oneFile) & return to outFile
end repeat
close access outFile
end open
I realize that this could be more simple in perl, but I'd like to keep this pure Applescript for now since I'm starting to grasp how this language is used.
Really helpful are the templates (menu
File
) and code-snippets (CTRL-Click into a script
).The template
Droplets->Recursive Image File Processing Droplet
provides everything. Here an edited version that does what you want: