Selecting a document by name

Morning all; I’m writing a Photoshop AppleScript that processes a number of files in turn. I’m fine with getting the list of files and opening them, but I can’t figure out how to then make a file the active one by name, which I need to do as I am cutting and pasting selections from one file to another. If I have a number of files open, but the one that I want has the name Fred1, how do I make that particular document active? I’m sure it is something completely simple, but I can’t see it. I’m using CS3, but the script should run on CS4 as well.

Hi,

if you have the (HFS) paths of the files you can retrieve a name with

set theName to name of (info for alias theFilePath)

Stefan, that’s not quite what I need. The situation is that I have a number of files open in photoshop, and that I need to make one specific file the current document. How do I do that?

You can refer to a document by index , by name or by filtering a parameter

tell application "Adobe Photoshop CS3"
	set current document to document 2
end tell
tell application "Adobe Photoshop CS3"
	set current document to document "myDocument"
end tell
tell application "Adobe Photoshop CS3"
	set current document to (get 1st document whose width > 300)
end tell