Photoshop CS3: create different filetypes/formats/names

I need some help with the following batch

Create from blabla.eps:
blabla.eps.lay (72dpi/no color profile/med.qual. jpg/preview tiff
blabal_100%.jpg (create selection from path1/invert selection/ fill with 255-255-255/72dpi/no color profile/qaul. 6/baseline (standard)
blabal_50%.jpg (create selection from path1/invert selection/ fill with 255-255-255/scale 50%/72dpi/no color profile/qaul. 6/baseline (standard)
blabal_25%.jpg (create selection from path1/invert selection/ fill with 255-255-255/scale 25%/72dpi/no color profile/qaul. 6/baseline (standard)
The .jpg’s are to be saved in a subfolder called JPEG_OUT

I already have the first part, but how do I get the rest in one run if possible

First part:


set processFolder to choose folder with prompt "Choose a folder that contains images to process"
tell application "Finder"
	if not (exists folder "LAY_OUT" of processFolder) then
		make new folder at processFolder with properties {name:"LAY_OUT"}
	end if
	set the destination_folder to folder "LAY_OUT" of processFolder as alias
end tell

tell application "Finder"
	try
		set listFiles to (files of contents of processFolder) as alias list
	on error
		set listFiles to (files of contents of processFolder) as alias as list
	end try
	repeat with thisFile in listFiles
		
		tell application "Adobe Photoshop CS3"
			with timeout of 300 seconds
				activate
				set display dialogs to never
				set UserPrefs to properties of settings
				set ruler units of settings to pixel units
				open thisFile
				tell current document
					if (bits per channel is sixteen) then set bits per channel to eight
					resize image resolution 72 resample method bicubic
					set docName to name
					set newFileName to (destination_folder as string) & docName & ".lay"
					save in file newFileName as Photoshop EPS appending no extension with options {class:EPS save options, embed color profile:false, encoding:medium quality JPEG, preview type:eight bit TIFF}
					close without saving
					tell application "Finder" to move thisFile to destination_folder with replacing
				end tell
			end timeout
		end tell
	end repeat

With a simple test I don’t think this is a million miles from what you want.

set Input_Folder to choose folder with prompt "Choose a folder that contains images to process" without invisibles
--
tell application "Finder"
	if not (exists folder "LAY_OUT" of Input_Folder) then
		set x to make new folder at Input_Folder with properties {name:"LAY_OUT"}
		set EPS_Folder to x as text
	else
		set EPS_Folder to folder "LAY_OUT" of Input_Folder as text
	end if
	if not (exists folder "JPEG_OUT" of folder EPS_Folder) then
		set y to make new folder at EPS_Folder with properties {name:"JPEG_OUT"}
		set JPEG_Folder to y as text
	else
		set JPEG_Folder to folder "JPEG_OUT" of folder EPS_Folder as text
	end if
	set File_List to files in Input_Folder
end tell
--
tell application "Adobe Photoshop CS2"
	set display dialogs to never
	set User_Rulers to ruler units of settings
	set ruler units of settings to pixel units
end tell
--
repeat with This_File in File_List
	tell application "Finder"
		set The_File to This_File as alias
	end tell
	tell application "Adobe Photoshop CS2"
		activate
		open The_File
		set Doc_Ref to the current document
		tell Doc_Ref
			set Doc_Name to name
			set Base_Name to my getBaseName(Doc_Name)
			if (bits per channel is sixteen) then
				set bits per channel to eight
			end if
			if (mode is not RGB) then
				change mode to RGB
			end if
			resize image resolution 72 resample method bicubic
			set New_Path to EPS_Folder & Base_Name & ".eps.lay"
			save Doc_Ref in file New_Path as Photoshop EPS with options {class:EPS save options, embed color profile:false, encoding:medium quality JPEG, preview type:eight bit TIFF} appending no extension with copying
			if exists (path items whose kind is clipping) then
				set Clip to (name of every path item whose kind is clipping)
				create selection path item (item 1 of Clip) feather amount 0 with antialiasing
				invert selection
				fill selection with contents {class:RGB color, red:255, green:255, blue:255}
				deselect
			end if
			set Pixel_Height to height
			set Saved_State_1 to current history state
			set New_Path to JPEG_Folder & Base_Name & "_100%.jpg"
			save Doc_Ref in file New_Path as JPEG with options {quality:6} with copying
			set current history state to Saved_State_1
			resize image height Pixel_Height / 2 resolution 72
			set New_Path to JPEG_Folder & Base_Name & "_50%.jpg"
			save Doc_Ref in file New_Path as JPEG with options {quality:6} with copying
			set current history state to Saved_State_1
			resize image height Pixel_Height / 4 resolution 72
			set New_Path to JPEG_Folder & Base_Name & "_25%.jpg"
			save Doc_Ref in file New_Path as JPEG with options {quality:6}
		end tell
		close current document without saving
	end tell
end repeat
--
tell application "Adobe Photoshop CS2"
	set ruler units of settings to User_Rulers
end tell
--
on getBaseName(fName)
	set baseName to fName
	repeat with idx from 1 to (length of fName)
		if (item idx of fName = ".") then
			set baseName to (items 1 thru (idx - 1) of fName) as string
			exit repeat
		end if
	end repeat
	return baseName
end getBaseName

GREAT!!
It workts.
But can it be tweaked a little bit more:
The script should give an error message if the color mode is NOT RGB
Is it possible to switch between paths when creating the jpg files (maybe by name, or path type - clipping path / selection?
I’m asking this because a lot of these EPS files can have more than one path: path1 is the clipping path to use for Print and path2 should be used for inverting and creating white around the object.

THANK YOU VERRY MUCH SO FAR

Sure you can target paths by name or index whatever is going to work in your work flow. I target “clipping” as “there can be only one” less to get mixed up. You could do away with path 2 as I have done by expanding the selection by a set pixel distance then filling with white. I also use this selection distance around the cilpping path to trim down our images that way they center in box nicely in Quark. Do you want to throw an error for not RGB or write a text log and continue with the process.

What is the string for targetting a path by name?
Continue and an errorlog.txt in in the EPS folder (Input_Folder would be nice

This should be pretty close.

set Input_Folder to choose folder with prompt "Choose a folder that contains images to process" without invisibles
--
tell application "Finder"
	if not (exists folder "LAY_OUT" of Input_Folder) then
		set x to make new folder at Input_Folder with properties {name:"LAY_OUT"}
		set EPS_Folder to x as text
	else
		set EPS_Folder to folder "LAY_OUT" of Input_Folder as text
	end if
	if not (exists folder "JPEG_OUT" of folder EPS_Folder) then
		set y to make new folder at EPS_Folder with properties {name:"JPEG_OUT"}
		set JPEG_Folder to y as text
	else
		set JPEG_Folder to folder "JPEG_OUT" of folder EPS_Folder as text
	end if
	set File_List to files in Input_Folder
end tell
--
tell application "Adobe Photoshop CS2"
	set display dialogs to never
	set User_Rulers to ruler units of settings
	set ruler units of settings to pixel units
end tell
--
repeat with This_File in File_List
	tell application "Finder"
		set The_File to This_File as alias
	end tell
	tell application "Adobe Photoshop CS2"
		activate
		open The_File
		set Doc_Ref to the current document
		tell Doc_Ref
			set Doc_Name to name
			set Base_Name to my getBaseName(Doc_Name)
			if (bits per channel is sixteen) then
				set bits per channel to eight
			end if
			if (mode is not RGB) then
				set Colour_Space to mode
				my Write_Log(EPS_Folder, Doc_Name, Colour_Space)
				close without saving
			else
				resize image resolution 72 resample method bicubic
				set New_Path to EPS_Folder & Base_Name & ".eps.lay"
				save Doc_Ref in file New_Path as Photoshop EPS with options {class:EPS save options, embed color profile:false, encoding:medium quality JPEG, preview type:eight bit TIFF} appending no extension with copying
				if exists (path items) then
					create selection path item "path2" feather amount 0 with antialiasing
					invert selection
					fill selection with contents {class:RGB color, red:255, green:255, blue:255}
					deselect
				end if
				set Pixel_Height to height
				set Saved_State_1 to current history state
				set New_Path to JPEG_Folder & Base_Name & "_100%.jpg"
				save Doc_Ref in file New_Path as JPEG with options {quality:6} with copying
				set current history state to Saved_State_1
				resize image height Pixel_Height / 2 resolution 72
				set New_Path to JPEG_Folder & Base_Name & "_50%.jpg"
				save Doc_Ref in file New_Path as JPEG with options {quality:6} with copying
				set current history state to Saved_State_1
				resize image height Pixel_Height / 4 resolution 72
				set New_Path to JPEG_Folder & Base_Name & "_25%.jpg"
				save Doc_Ref in file New_Path as JPEG with options {quality:6} with copying
				close without saving
			end if
		end tell
	end tell
end repeat
--
tell application "Adobe Photoshop CS2"
	set ruler units of settings to User_Rulers
end tell
--
on getBaseName(fName)
	set baseName to fName
	repeat with idx from 1 to (length of fName)
		if (item idx of fName = ".") then
			set baseName to (items 1 thru (idx - 1) of fName) as string
			exit repeat
		end if
	end repeat
	return baseName
end getBaseName
--
on Write_Log(EPS_Folder, Doc_Name, Colour_Space)
	set The_Log to EPS_Folder & "None RGB Images.txt"
	try
		open for access file the The_Log with write permission
		write (return & Doc_Name & " was " & Colour_Space) to file the The_Log starting at eof
		close access file the The_Log
	on error
		try
			close access file the The_Log
		end try
	end try
end Write_Log

Great soo far!!

Just two things:

Is it possible to have the script check for pathname “path2” first, if not existing, use pathname “path1” and if no path at all just go on and create the jpeg’s
Because there can be path2 for only webimages path1 for both web and print and sometimes we have images with no path(s) at all

I would like to have the .eps.lay image to be in CMYK mode (our biggest customer has a printer witch creates a light color even if the color is 255,255,255 in RGB Images
I’tried to change this but then all the jpeg’s are alse in CMYK?

Many thanks for all your input!!

Untested but it should be near.

set Input_Folder to choose folder with prompt "Choose a folder that contains images to process" without invisibles
--
tell application "Finder"
	if not (exists folder "LAY_OUT" of Input_Folder) then
		set x to make new folder at Input_Folder with properties {name:"LAY_OUT"}
		set EPS_Folder to x as text
	else
		set EPS_Folder to folder "LAY_OUT" of Input_Folder as text
	end if
	if not (exists folder "JPEG_OUT" of folder EPS_Folder) then
		set y to make new folder at EPS_Folder with properties {name:"JPEG_OUT"}
		set JPEG_Folder to y as text
	else
		set JPEG_Folder to folder "JPEG_OUT" of folder EPS_Folder as text
	end if
	set File_List to files in Input_Folder
end tell
--
tell application "Adobe Photoshop CS2"
	set display dialogs to never
	set User_Rulers to ruler units of settings
	set ruler units of settings to pixel units
end tell
--
repeat with This_File in File_List
	tell application "Finder"
		set The_File to This_File as alias
	end tell
	tell application "Adobe Photoshop CS2"
		activate
		open The_File
		set Doc_Ref to the current document
		tell Doc_Ref
			set Doc_Name to name
			set Base_Name to my getBaseName(Doc_Name)
			if (bits per channel is sixteen) then
				set bits per channel to eight
			end if
			if (mode is not RGB) then
				set Colour_Space to mode
				my Write_Log(EPS_Folder, Doc_Name, Colour_Space)
				close without saving
			else
				resize image resolution 72 resample method bicubic
				set Saved_State_1 to current history state
				change mode to CMYK
				set New_Path to EPS_Folder & Base_Name & ".eps.lay"
				save Doc_Ref in file New_Path as Photoshop EPS with options {class:EPS save options, embed color profile:false, encoding:medium quality JPEG, preview type:eight bit TIFF} appending no extension with copying
				set current history state to Saved_State_1
				if exists path item "path2" then
					create selection path item "path2" feather amount 0 with antialiasing
					invert selection
					fill selection with contents {class:RGB color, red:255, green:255, blue:255}
					deselect
				else
					if exists path item "path1" then
						create selection path item "path1" feather amount 0 with antialiasing
						invert selection
						fill selection with contents {class:RGB color, red:255, green:255, blue:255}
						deselect
					end if
				end if
				set Pixel_Height to height
				set Saved_State_2 to current history state
				set New_Path to JPEG_Folder & Base_Name & "_100%.jpg"
				save Doc_Ref in file New_Path as JPEG with options {quality:6} with copying
				set current history state to Saved_State_2
				resize image height Pixel_Height / 2 resolution 72
				set New_Path to JPEG_Folder & Base_Name & "_50%.jpg"
				save Doc_Ref in file New_Path as JPEG with options {quality:6} with copying
				set current history state to Saved_State_2
				resize image height Pixel_Height / 4 resolution 72
				set New_Path to JPEG_Folder & Base_Name & "_25%.jpg"
				save Doc_Ref in file New_Path as JPEG with options {quality:6} with copying
				close without saving
			end if
		end tell
	end tell
end repeat
--
tell application "Adobe Photoshop CS2"
	set ruler units of settings to User_Rulers
end tell
--
on getBaseName(fName)
	set baseName to fName
	repeat with idx from 1 to (length of fName)
		if (item idx of fName = ".") then
			set baseName to (items 1 thru (idx - 1) of fName) as string
			exit repeat
		end if
	end repeat
	return baseName
end getBaseName
--
on Write_Log(EPS_Folder, Doc_Name, Colour_Space)
	set The_Log to EPS_Folder & "None RGB Images.txt"
	try
		open for access file the The_Log with write permission
		write (return & Doc_Name & " was " & Colour_Space) to file the The_Log starting at eof
		close access file the The_Log
	on error
		try
			close access file the The_Log
		end try
	end try
end Write_Log

Many thanks again - This will save me a lot of work