Ian The only merge options in PS scripting do not include what you are doing in the GUI you can merge layers or spot channels into the composite colour space. Do you have any composite stuff or just spot plates? if its the latter the order of the repeat loop for opening the images would not matter you would just need the end of the name string to look up the associated data from your text file. In the example shown a file named AAA would be coloured Pantone Reflex Blue C a file named BBB Pantone 185 C an so on. I have had a little time to add some more. As you can see I still haven’t got the handler working right yet.
My test text file looks like this:
0054, 100, 92, 1, 1, Pantone Reflex Blue C
0185, 0, 97, 74, 0, Pantone 185 C
0225, 13, 87, 0, 0, Pantone 225 C
0360, 67, 0, 87, 0, Pantone 360 C
0635, 36, 0, 7, 0, Pantone 635 C
File names like this:
200000_XX 0054.tif
200000_XX 0185.tif
200000_XX 0225.tif
200000_XX 0360.tif
200000_XX 0635.tif
set CV_Tables to alias choose file with prompt "Where is the Colour Values text file?" without invisibles
set CVT to read (CV_Tables)
--
set inputFolder to choose folder with prompt "Where is the folder of image files?" without invisibles
--
tell application "Finder"
set filesList to files in inputFolder
set myChannels to count of filesList
set theFileA to item 1 of filesList as alias
end tell
--
tell application "Adobe Photoshop CS2"
activate
set display dialogs to never
open theFileA
set docRefA to the current document
tell docRefA
set docNameA to name of docRefA
change mode to multichannel
set docBaseName to getBaseName(docNameA) of me
set colourID to items 11 thru 14 of docBaseName as string
-- This is what I would have liked in a handler!!!
repeat with x from 1 to (count of paragraphs) of CVT of me
set y to paragraph x of CVT of me as string
set z to count of words of y
if word 1 of y is colourID then
set myPMS to words 6 thru z of y
set ASTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to space
set myPMS to myPMS as string
set AppleScript's text item delimiters to ASTID
set myC to word 2 of y as integer
set myM to word 3 of y as integer
set myY to word 4 of y as integer
set myK to word 5 of y as integer
end if
set properties of channel 1 to ¬
{name:myPMS, kind:spot color channel, opacity:0, visible:true, channel color:{class:CMYK color, cyan:myC, magenta:myM, yellow:myY, black:myK}}
end repeat
end tell
end tell
--
repeat with i from 2 to myChannels
tell application "Finder"
set theFileB to item i of filesList as alias
end tell
tell application "Adobe Photoshop CS2"
open theFileB
set docRefB to the current document
tell docRefB
set docNameB to name of docRefB
set docBaseName to getBaseName(docNameB) of me
set colourID to items 11 thru 14 of docBaseName as string
-- This is what I would have liked in a handler!!!
repeat with x from 1 to (count of paragraphs) of CVT of me
set y to paragraph x of CVT of me as string
set z to count of words of y
if word 1 of y is colourID then
set myPMS to words 6 thru z of y
set ASTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to space
set myPMS to myPMS as string
set AppleScript's text item delimiters to ASTID
set myC to word 2 of y as integer
set myM to word 3 of y as integer
set myY to word 4 of y as integer
set myK to word 5 of y as integer
end if
end repeat
duplicate channel 1 to end of docRefA
end tell
close docRefB without saving
tell docRefA
set properties of last channel to ¬
{name:myPMS, kind:spot color channel, opacity:0, visible:true, channel color:{class:CMYK color, cyan:myC, magenta:myM, yellow:myY, black:myK}}
end tell
end tell
end repeat
--
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