Re: How do I loop through already open psds?
Re: How do I loop through already open psds?
- Subject: Re: How do I loop through already open psds?
- From: Stan Cleveland <email@hidden>
- Date: Mon, 09 Oct 2006 12:30:56 -0700
- Thread-topic: How do I loop through already open psds?
On 10/8/06 11:38 PM, Patrik B. wrote:
> I just started applescripting photoshop cs2 and tried looping through open
> documents but for some reason it did the action always to document 1 instead
> of the next in line. Why is this?
>
> My code is something like this:
>
> tell app "adobe photoshop cs2"
> set mydocs to documents
> repeat with i in mydocs
> -- my action on i
> end
> end
You just need to set each document in turn to be the "current document",
like this:
tell application "Adobe Photoshop CS2"
set mydocs to documents
repeat with thisDoc in mydocs
set current document to thisDoc
-- my action on thisDoc
end repeat
end tell
Incidentally, the variable "i" (and "j", "k", etc. as needed) is
traditionally used for an incrementing numeric index (usually starting at
1). In this case, using something like "thisDoc" is more descriptive and
understandable.
> Also I tried doing a search and replace of text via applescript but could
> not find a command for that in the dictionairy is this function even
> scriptable?
I'm also unable to get search/replace of substrings to work in Photoshop CS.
However, here's code to replace the entire string of a text layer:
tell application "Adobe Photoshop CS2"
tell current document
-- by layer index
set contents of text object of art layer 1 to "New text"
-- or by layer name
set contents of text object of art layer "Text" to "New text"
end tell
end tell
Perhaps someone else has an idea for substring replacement?
Stan C.
--
"There are two types of complex systems: those that have grown out of
simpler systems and those that do not work." -- Unknown
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden