Newbie: Droplet to interact with Photoshop

I’m a graphic designer and I can’t figure it out how to make an script to interact with Photoshop.
What I need is a droplet to open a JPG or TIFF in Photoshop and then set the background layer name to be the same as the file’s name.
Another question is, will this droplet work in Mac OS 9 as in Mac OS X?
Thank you for yor help!!.

First off, are you sure you have scripting additions installed. If you’re using Pshop CS I think it comes installed. If you are using PS 7, you will need to go to adobe’s website and download photoshop scripting.

Once you are sure of that, the following script should help you out. This is a script I wrote to put the file name into the Title feild in File Info. You can pull the file info up by opening the document, the going to the file menu and choosing file info. You should be able to easily modify this to work on layers. If not, reply back, and I’ll help you out.

BTW, this droplet will do all files and subfolders if you drop a folder on it.

on open these_items
–determine if folder or file
repeat with i from 1 to the count of these_items
set this_item to item i of these_items)
set the item_info to info for this_item
if folder of the item_info is true then
process_folder(this_item)
else if (alias of the item_info is false) then
process_item(this_item)
end if
end repeat
end open
– this sub-routine processes folders until it’s a file
on process_folder(this_folder)
set these_items to list folder this_folder without invisibles
repeat with i from 1 to the count of these_items
set this_item to alias ((this_folder as text) & (item i of these_items))
set the item_info to info for this_item
if folder of the item_info is true then
process_folder(this_item)
else if (alias of the item_info is false) then
process_item(this_item)
end if
end repeat
end process_folder
on process_item(this_item)
–get the file name
tell application “Finder” to set file_name to name of this_item
–set the file name to the title in file info of file
tell application “Adobe Photoshop 7.0”
open this_item showing dialogs never
set title of info of document file_name to file_name
close document file_name with saving
end tell
end process_item

Thank you for your answer. I tried your script with a modification in the last part to do what I need, but it doesn’t work… this my script:

tell application “Adobe Photoshop 7.0”
open this_item
make new art layer at beginning of current document with properties {name:“file_name”}
close document file_name with saving
end tell

When I try to compile it, it gives me an eror highting the word layer.
Any idea?

You’re close, but you’re going through the same exact thing I’ve been going through… you have to write the line just they way they like it.

make new art layer with properties {name:"file_name"} at beginning of current document

All I did was moved at beginning of current document

Now, if you want “file_name” to actaully be the file name, you need to take it out of the quotes. file_name is defined as a variable within the script example I posted originally…

tell application "Finder" to set file_name to name of this_item

Otherwise, the new layers you create with the current line of code you have will all just be named file_name. BTW, there are many helpful lines of code, including the making the new layer code in the documentation for Photoshop scripting.

gcat,

What do you mean by “first layer” ?
If i’ts the one at bottom of the palette, this is the last layer!

Here’s a script processing one (and only one) file at a time.
You can test it from your Script Editor or save it as a dropplet.

-- this handler is called when you drag a file onto the icon of the droplet.
on open (listFile)
	if (count of listFile) > 1 then
		display dialog "Only one file at a time !" buttons "OK" default button 1 with icon 1
		return
	else
		set theFile to listFile as alias
	end if
	processFile(theFile)
end open

-- this handler is called when you run the script by double-clicking on it or from within Script Editor.
on run
	tell application "Finder" to set listFile to selection
	open (listFile)
end run

-- this is where we do the stuff
on processFile(theFile)
	tell application "Adobe Photoshop 7.0"
		activate
		open theFile
		tell document 1
			set docName to name
			set name of layer -1 to docName
		end tell
	end tell
end processFile

Let us know if it helps.

Well that’s interesting ionah. I didn’t realize you could do tell document 1 … end tell.

Either way gcat, if you use ionah’s method you can use

set name of layer -1 to docName

to change the very bottom layer, which is known as the last layer or…

set name of layer 1 to docName

the change the very top layer, which is known as the first layer. However, ionah’s version will not make a new layer for the file name. It will just take the first existing layer and change it to the file name.

If you just use the correction I posted earlier, your script should work. If you want your file name layer to be at the bottom change begining to end

:oops:

Both.

If you need more help, I suggest you start a new topic and PM me, so I can be informed.

:wink: