I have an applescript which runs at the end of a Lightroom photo export. It takes a published set of photos and automatically saves them to two different resolutions and puts them in separate folders. Feel free to use it if you need this same kind of functionality. It creates two folders, “High Res” and “Low Res” and then takes the exported photos and resaves two sets of high res and low res photos, each in their own folder. The final step of the script is what I’m trying to figure out. Once the low res and high res folders and files have been saved, I want to delete the originally published jpgs from the folder root. Seems like I have the proper code for this below, however I am getting the following error dialogue:
Can’t get <> “/Users/mac/Dropbox/Client Photos/Colleen Long/3423 Gloucester/” of application “Finder”.
Can someone show me how to get the delete working?
Thanks!!
My Code:
on open of myFiles
tell application "Finder"
set p to (target of front Finder window) as text
make new folder at p with properties {name:"Low Res"}
end tell
set newSizes to {2048}
repeat with aFile in myFiles
set filePath to aFile's POSIX path
set bPath to (do shell script "dirname " & quoted form of filePath)
tell application "System Events" to set fileName to aFile's name
repeat with newSize in newSizes
do shell script "sips " & quoted form of aFile's POSIX path & " -Z " & newSize & " --out " & quoted form of (bPath & "/Low Res/" & rename(fileName, "low-res") as text)
end repeat
end repeat
tell application "Finder"
set p to (target of front Finder window) as text
make new folder at p with properties {name:"High Res"}
end tell
set newSizes to {5000}
repeat with aFile in myFiles
set filePath to aFile's POSIX path
set bPath to (do shell script "dirname " & quoted form of filePath)
tell application "System Events" to set fileName to aFile's name
repeat with newSize in newSizes
do shell script "sips " & quoted form of aFile's POSIX path & " -Z " & newSize & " --out " & quoted form of (bPath & "/High Res/" & rename(fileName, "high-res") as text)
end repeat
end repeat
tell application "Finder"
delete (every document file of folder bPath whose name ends with ".jpg")
end tell
end open
on rename(fName, fSize)
do shell script “sed 's/high-res/” & fSize & "/’ <<< " & quoted form of fName
end rename