Problem setting IPTC-keywords in Photoshop

Hi all

Whenever I paste the following string by copy/paste manually into the keywords field:

Photoshop CS converts it to:

(wanted result)

(simply close the file info panel after pasting and reopen it)

BUT!

If I do this with AppleScript Photoshop converts it to:

““Büro”” ““Computer”” ““Frau”” ““Geschäftsmann”” ““innen”” ““Laptop”” ““Manager”” ““Mann”” ““Notebook”” ““Schreibtisch”” ““Buero”” ““Geschaeftsmann””

Strange somehow…

Does anyone know how to format the string in AppleScript so we get the result we want?

I know that this is not strict IPTC-NAA 4.1. If we follow the specification exactly:

will not be converted by Photoshop. It results in:

Script for testing:


property _stichwoerter_format : 1

set _temp to "Büro; Computer; Frau; Geschäftsmann; innen; Laptop; Manager; Mann; Notebook; Schreibtisch; Buero; Geschaeftsmann"

if last character of _temp is " " then set _temp to (characters 1 thru -2 of _temp) as Unicode text
if _stichwoerter_format = 0 then
	set _temp to _SaR(_temp, "; ", " ")
else if _stichwoerter_format = 1 then
	set _temp to _SaR(_temp, "; ", "\" \"") -- <- This is the crux!
	set _temp to "\"" & _temp & "\""
end if

tell application "Adobe Photoshop CS"
	tell document 1
		tell info
			set keywords to _temp
		end tell
	end tell
end tell

return _temp

-- Suchen und Ersetzen
on _SaR(_text, _search, _replace)
	set AppleScript's text item delimiters to _search
	set _text to every text item of _text
	set AppleScript's text item delimiters to _replace
	set _text to _text as string
	set AppleScript's text item delimiters to ""
	return _text
end _SaR

Any help is appreciated! Thanks in advance!
Thomas

Will this work:

property _stichwoerter_format : 1

set _temp to "Büro; Computer; Frau; Geschäftsmann; innen; Laptop; Manager; Mann; Notebook; Schreibtisch; Buero; Geschaeftsmann"
set ATD to AppleScript's text item delimiters
set AppleScript's text item delimiters to "; "
set _temp to every text item of _temp
set AppleScript's text item delimiters to ATD

tell application "Adobe Photoshop CS"
	tell document 1
		tell info
			set keywords to _temp
		end tell
	end tell
end tell

return _temp

-- Suchen und Ersetzen
on _SaR(_text, _search, _replace)
	set AppleScript's text item delimiters to _search
	set _text to every text item of _text
	set AppleScript's text item delimiters to _replace
	set _text to _text as string
	set AppleScript's text item delimiters to ""
	return _text
end _SaR

Pretty cool! It works! It’s perfect! :smiley:

Thank you very much and many many kudos!
Thomas

I will try this myself when I get the chance. Bashed my head against the desk many a time over this issue. Thanks Jerome for a possible solution.