Working with the text in the applescript result window

Hello,
I am using applescript to extract text from text layers in a photoshop document. The result shows up in the result window.
Can I have applescript now capture that text, copy it to the clipboard and paste it into Photoshops file info area, in either the keywords or description areas???
Is that doable???
thanks!
Barbara

Hello again,
One additional thought (in addition to my initial post), if I can’t place it into photoshops metadata area of keywords or description, what about the comments area of the get info dialog box for each image.
thanks again…
barbara

Hi Barbara,

real scripters don’t need the clipboard at all :wink:
This puts the text into the description field of the information window

tell application "Adobe Photoshop CS3"
	tell document 1
		set t to contents of text object of layers whose kind is text layer
		set {ASTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, return}
		set caption of info to t as text
		set AppleScript's text item delimiters to ASTID
	end tell
end tell

Hi Stefen,
I just wrote to you on our other (original forum)!!!
YOU ARE A GENIUS!!!
I am going to now attempt to get this to batch a bunch of images in a folder…
Thank you thank you thank you!!!
barbara :smiley:

Hi Stefen,
OK…I am almost there… here is what I have do far… trying to get it to open a bunch of psd files in a folder so this can be done as a batch…

beep
display dialog “Select a folder with images to add text layer contents to file description box.”
set chosenFolder to choose folder with prompt “Choose folder to process:”
tell application “Finder”
set theFiles to files of chosenFolder
end tell
tell application “Adobe Photoshop CS3”
set display dialogs to never
close every document saving yes
repeat with thisFile in theFiles
set filePath to thisFile as alias
setFilename to name of thisFile
tell application “Adobe Photoshop CS3”
activate
open filePath
tell document 1
repeat with thisFile in theFiles
– set filePath to thisFile as alias
– set fileName to name of thisFile
set t to (contents of text object of layers whose kind is text layer)
set {ASTID, AppleScript’s text item delimiters} to {AppleScript’s text item delimiters, ", "}
set caption of info to t as text
set AppleScript’s text item delimiters to ASTID

			end repeat
		end tell
		
	end tell
end repeat

end tell

it is dying on the following line…

“setFilename to name of thisFile”

any thoughts…I thought I had it…
thanks
barbara

some problems:
¢ only the Finder, System Events and the scripting addition info for know the name of a file
¢ split set Filename
¢ the second repeat loop is useless

and I added a line to save each document
try this


beep
display dialog "Select a folder with images to add text layer contents to file description box."
set chosenFolder to choose folder with prompt "Choose folder to process:"
tell application "Finder"
	set theFiles to files of chosenFolder
end tell
tell application "Adobe Photoshop CS3"
	set display dialogs to never
	close every document saving yes
	repeat with thisFile in theFiles
		set Filename to name of (info for thisFile as alias)
		tell application "Adobe Photoshop CS3"
			activate
			open (thisFile as alias)
			tell document 1
				set t to (contents of text object of layers whose kind is text layer)
				set {ASTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, ", "}
				set caption of info to t as text
				set AppleScript's text item delimiters to ASTID
				close it saving yes
			end tell
		end tell
	end repeat
end tell

Ahhhhhhhh…
As you can see, I have a long way to go to learning this stuff… I totally understand though, what I did wrong… thanks for clarifying :wink:
One more thought…I noticed if I have stuff already in the description, then this script overwrites what was there with the stuff on the text layers… that’s something I didn’t think of… is there any way to prevent it from overwriting whatever already exists in the description. Sorry about that, but I just tested a bunch of real files that had SKU numbers as well as some other important info in the description area, and our script now overwrites what was there…
Is that possible to just append to the description our new stuff?
thanks so much!
barbara


.
set {ASTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, ", "}
tell (caption of info) to if it is not "" then copy it to beginning of t
set caption of info to t as text
set AppleScript's text item delimiters to ASTID
.

wow!
not that I would have never figured out in a million years :wink:
Thank you so much for all your help…
I am forever grateful :D:D

you’re welcome :slight_smile: