Applescript for Photoshop doing different actions for different images

Applescript for Photoshop doing different actions for different images based on their dimensions.

Hello i am trying to make a script that uses different photoshop actions for different dimensions of files in one folder.

property SourceFolder : missing value
property DestinationFolder : missing value

if SourceFolder = missing value then
set SourceFolder to (choose folder with prompt “Choose RGB:”)
set DestinationFolder to (choose folder with prompt “Choose JPG:”)
else

tell application "Finder"
	set theFolders to every item of entire contents of SourceFolder as list
	repeat with thisFolder in theFolders
		make new alias file at DestinationFolder to thisFolder
	end repeat
end tell

end if

tell application “Finder”
set filesList to (files of entire contents of SourceFolder whose name extension is “tif”) as alias list
end tell

tell application “Adobe Photoshop CS6”
activate

set stringToBeDisplayed to “Choose the size”
display dialog stringToBeDisplayed buttons {"Large-475×277³, "Medium-292×130³, "Small-180×100³}

if result = {button returned:"Large-475×277³} then
do action “Default_Large.atn” from “Macintosh HD/Users/rigbeas/Library/Application Support/Adobe/Adobe Photoshop CS6/Presets/Actions”

else if result = {button returned:"Medium-292×130³} then
do action “Default_Medium.atn” from “Macintosh HD/Users/rigbeas/Library/Application Support/Adobe/Adobe Photoshop CS6/Presets/Actions”

else
do action “Default_Small.atn” from “Macintosh HD/Users/rigbeas/Library/Application Support/Adobe/Adobe Photoshop CS6/Presets/Actions”

end if

end tell

end open

So Applescript must define with photoshop the dimension of an image and choose the right ACTION for it…

Hi. Please enclose sample code within Applescript tags.
If using predefined actions, the dimensions don’t need to be defined, as the script serves only as a trigger. Since your naming convention is consistent, I’d condense all those calls into one. You also need open/save/close commands.

tell application "Adobe Photoshop CS3"
	repeat with aFile in filesList
		open aFile
		set actionWord to (display dialog "Choose the size" buttons {"Large-475×277", "Medium-292×130", "Small-180×100"})'s button returned's word 1
		tell document 1
			do action "Default_" & actionWord from "Default Actions"
			save it in file (destinationFolder & name) as JPEG --assumes an HFS path
			close
		end tell
	end repeat
end tell

Sorry for the very late reply. Been very busy on non applescript work.

So you mean it like this?

property SourceFolder : missing value
property destinationFolder : missing value

if SourceFolder = missing value then
	set SourceFolder to (choose folder with prompt "Choose RGB:")
	set destinationFolder to (choose folder with prompt "Choose JPG:")
else
	
	tell application "Finder"
		set theFolders to every item of entire contents of SourceFolder as list
		repeat with thisFolder in theFolders
			make new alias file at destinationFolder to thisFolder
		end repeat
	end tell
end if

tell application "Finder"
	set filesList to (files of entire contents of SourceFolder whose name extension is "tif") as alias list
end tell

tell application "Adobe Photoshop CS6"
	repeat with aFile in filesList
		open aFile
		set actionWord to (display dialog "Choose the size" buttons {"Large-475×277", "Medium-292×130", "Small-180×100"})'s button returned's word 1
		tell document 1
			do action "Default_" & actionWord from "Default Actions"
			save it in file (destinationFolder & name) as JPEG --assumes an HFS path
			close
		end tell
	end repeat
end tell