Help with Photoshop Folder Action (almost there!)

Hi,

I need some help to make this Folder Action behave exactly as I need. But first, I need to thank jonn8 and TrashMan. I blatantly used one of their scripts and with the help of the Photoshop Applescript Scripting Guide managed to make it do what I want (mostly).

This is the script I need to modify.


property dialog_timeout : 30
property target_folder_name : "Output"

on adding folder items to this_folder after receiving added_items
	set outputFolder to (path to desktop as string) & target_folder_name & ":"
	try
		get outputFolder as alias
	on error
		tell application "Finder" to make new folder at desktop with properties {name:target_folder_name}
	end try
	set process_count to 0
	tell application "Photoshop 9.0.2"
		set display dialogs to never
		close every document saving no
		repeat with aFile in added_items
			if (aFile as string) ends with "pdf" then
				try
					open (aFile as alias) as PDF with options ¬
						{class:PDF open options, crop page:media box, mode:CMYK, resolution:100, use antialias:true}
					set docRef to current document
					tell docRef
						set docName to name
						set newFileName to (outputFolder & docName)
						set myOptions to {class:TIFF save options, byte order:IBM PC, embed color profile:false, image compression:LZW, save alpha channels:true, save layers:false, save spot colors:true}
						save in file newFileName as TIFF with options myOptions appending lowercase extension with copying
						close without saving
					end tell
					set process_count to process_count + 1
				end try
			end if
		end repeat
	end tell
	activate
	set the_plural to "s"
	if process_count = 1 then set the_plural to ""
end adding folder items to

It does exactly what I want, with two exceptions. Firstly, I need the resulting tif files to have “.tif” placed at the end of the file name. And secondly, I need the action to delete the input file after it’s finished processing. Any help with either or both of these requests would be greatly appreciated.

Thanks,

Nicholas

change:

save in file newFileName as TIFF with options myOptions appending lowercase extension with copying

to:

save in file newFileName as TIFF appending lowercase extension with options myOptions appending lowercase extension with copying

To move the file to the trash add the following after the close line add (you might have to coerce to an alias):

tell application "Finder" to delete aFile

This worked great. Much thanks.

However, I still can’t get the extension to appear at the end of the name. I put in

save in file newFileName as TIFF appending lowercase extension with options myOptions appending lowercase extension with copying

as you suggested, but the script is now telling me that: The “class DcXt” parameter is specified more than once.

Nevermind. A colleague suggested that I simply add a

& ".tif"

at the end of docName and that worked great. I feel like I’m cheating a little bit. But, whatever works! Thanks again for your help.

nicho, since I upgraded to CS2 “appending lowercase extension” has never worked for me and in all my scripts I did the same “cheat”. Jerome you specify this twice in your suggestion is this something you’ve found that makes this work? must admit not tried this yet. CS2 seems very buggy over CS1. CS3 is too pricy to make such a quick jump to.

This works:

set thefolder to (choose folder) as string
set newFileName to thefolder & "Test"
tell application "Adobe Photoshop CS2"
	tell current document to save in file newFileName as TIFF with options {class:TIFF save options, byte order:IBM PC, embed color profile:false, image compression:LZW, save alpha channels:true, save layers:false, save spot colors:true} appending lowercase extension
end tell

This does not:

set thefolder to (choose folder) as string
set newFileName to thefolder & "Test"
tell application "Adobe Photoshop CS2"
	tell current document to save in file newFileName as TIFF appending lowercase extension with options {class:TIFF save options, byte order:IBM PC, embed color profile:false, image compression:LZW, save alpha channels:true, save layers:false, save spot colors:true}
end tell

Note the location of the appending option. I admit that I did not test the lines of code, and I believe that I noted that in my comments in the other thread. I also the appending option in twice in my earlier post here for some reason, over zelous with the comand “v” I guess. I just tested these two and with the appending at the end I get a lower case “.tif” added to the name when saved. I have noticed that sometimes you need to rearange the options from the order that the dictionary lists them in to get them all to work. Also that sometimes you need to set some options (such as when making a new item) after the item is created instead of setting them in the options property list.