I needed a workflow that put the resized images into a sub folder of the originals, so made the following amendments.
It can handle multiple file selections within differing directories and place the resize-x folder within the respective directory relative to the original image.
Open the "Process image(s)" AppleScript block in the workflow
Find the following lines in the downloadable version (Lines 27-28)
set myPath to this_file
end if
And insert the following after it that will create a new directory next to the file being resized in the format of 'resize-{resize-width}' (resize-500, resize-1024 for example)
-- Remove the file name from the end of the path string
set filePath to characters 1 thru -((offset of "/" in (reverse of items of myPath as string)) + 1) of myPath as text
set fileName to name of (info for myPath)
-- Create a full path to the folder that we want.
set resizeFolderName to ((filePath as text) & "/resize-" & (target_width as text) & "/") as text
-- Check for the resize-x folder and create it if not present
if folderExists(resizeFolderName) then
set outputFolder to resizeFolderName
else
set createThisFolder to POSIX file filePath as alias
tell application "Finder" to make new folder in createThisFolder with properties {name:"resize-" & target_width}
set outputFolder to resizeFolderName
end if
Change the following line (Originally on line 38, with the addition of the above, its now on line 60)
save this_image in myPath
to
save this_image in outputFolder & fileName
Add the following function to the end of the file:
on folderExists(theFolder)
tell application "Finder"
try
set thisFolder to the POSIX path of theFolder
set thisFolder to (POSIX file thisFolder) as text
-- set thisFolder to theFolder as alias
return true
on error err
return false
end try
end tell
end folderExists
Or, if you want the whole script in one thing, its on a Gist here: https://gist.github.com/danstreeter/23fe01074034832fec09c0b633522559