Photoshop and the Original Folder - The Revenge

This is a script to process files in a folder with Photoshop and save them in the same folder in eps:

on open stuffDropped
repeat with thisItem in stuffDropped
tell application “Finder”
if kind of item thisItem is “folder” then
set countEachFile to (count thisItem each file)
if countEachFile is greater than 1 then
set stuffDropped to get every file of thisItem as alias list
else if countEachFile is equal to 1 then
set stuffDropped to get every file of thisItem as alias as list
else – countEachFile is 0
exit repeat
end if
else
set stuffDropped to thisItem as list
end if
end tell
repeat with thisFile in stuffDropped
tell application “Adobe Photoshop 7.0”
activate
open thisFile showing dialogs never
set myOptions to {class:EPS save options, encoding:maximum quality JPEG, embed color profile:true, preview type:JPEG Mac OS}
– Run Photoshop action to USM, convert to CMYK
do action “Action 1 (AutoLevels)” from “Guido Actions”
save current document as Photoshop EPS ¬
with options myOptions in file (thisFile as string) appending lowercase extension
close current document saving no
end tell
end repeat
end if
end repeat
end open

The thing is, I don’t always want Photoshop to activate, sometimes I prefer it to stay in the background, so I tried to put a condition just before the PS section, like this (in red the changes):

on open stuffDropped
repeat with thisItem in stuffDropped
tell application “Finder”
if kind of item thisItem is “folder” then
set countEachFile to (count thisItem each file)
if countEachFile is greater than 1 then
set stuffDropped to get every file of thisItem as alias list
else if countEachFile is equal to 1 then
set stuffDropped to get every file of thisItem as alias as list
else – countEachFile is 0
exit repeat
end if
else
set stuffDropped to thisItem as list
end if
end tell
display dialog “Photoshop in foreground?” buttons {“Yep”, “Nope”} default button 2
if the button returned of the result is “Yep” then

repeat with thisFile in stuffDropped
tell application “Adobe Photoshop 7.0”
activate
open thisFile showing dialogs never
set myOptions to {class:EPS save options, encoding:maximum quality JPEG, embed color profile:true, preview type:JPEG Mac OS}
– Run Photoshop action to USM, convert to CMYK
do action “Action 1 (AutoLevels)” from “Guido Actions”
save current document as Photoshop EPS ¬
with options myOptions in file (thisFile as string) appending lowercase extension
close current document saving no
end tell
end repeat
else
repeat with thisFile in stuffDropped
tell application “Adobe Photoshop 7.0”
open thisFile showing dialogs never
set myOptions to {class:EPS save options, encoding:maximum quality JPEG, embed color profile:true, preview type:JPEG Mac OS}
– Run Photoshop action to USM, convert to CMYK
do action “Action 1 (AutoLevels)” from “Guido Actions”
save current document as Photoshop EPS ¬
with options myOptions in file (thisFile as string) appending lowercase extension
close current document saving no
end tell
end repeat
end if
end repeat
end open

Of course, it doesn’t work, returning an “Invalid File Path” error.
Why? Any Idea?
Thank you,
Guido

Have you saved the set of actions “Guido Actions” to the disk in the PhotoShop Actions folder? The actual save to disk is necessary after creating the action set; at least that seems to be the case.

If it has been saved, try commenting out the action call and see what you get. After taking a look your code and trying it with PSD7/OS9 & PSDCS/OSX, it works fine on two different systems. I of course had to comment out your call to a PSD action. That may be the culprit. Take a look at what the action is doing possibly.

Here’s the code I used:


on open stuffDropped
repeat with thisItem in stuffDropped
tell application “Finder”
if kind of item thisItem is “folder” then
set countEachFile to (count thisItem each file)
if countEachFile is greater than 1 then
set stuffDropped to get every file of thisItem as alias list
else if countEachFile is equal to 1 then
set stuffDropped to get every file of thisItem as alias as list
else – countEachFile is 0
exit repeat
end if
else
set stuffDropped to thisItem as list
end if
end tell

	repeat with thisFile in stuffDropped
		tell application "Adobe Photoshop 7.0"
			activate
			open thisFile showing dialogs never
			set myOptions to {class:EPS save options, encoding:maximum quality JPEG, embed color profile:true, preview type:JPEG Mac OS}
			--  Run Photoshop action to USM, convert to CMYK 
			--  do action "Action 1 (AutoLevels)" from "Guido Actions"
			save current document as Photoshop EPS ¬
				with options myOptions in file (thisFile as string) appending lowercase extension
			close current document saving no
		end tell
	end repeat

end repeat

end open

There are some other workarounds, but let’s see what happens w/o the action call.

As to Photoshop in the background, in my testing, certain functions can NOT be performed by PhotoShop if it is HIDDEN. However, if you activate PhotoShop and then activate something else, say the Finder, PhotoShop will run without doing the video updates as though it is in the background. The key is to NOT HIDE PhotoShop, merely activate something else. This can speed up your script tremendously.

I hope this helps
Jeff

Hi there,
I’m quite new to scripting and so far have only used photoshop droplets. I really like the script. Makes my job much easier. Is there any way to add that the original files will be moved to the trash? Much help woul dbe appreciated.
Thanks j

on open stuffDropped
repeat with thisItem in stuffDropped
tell application “Finder”
if kind of item thisItem is “folder” then
set countEachFile to (count thisItem each file)
if countEachFile is greater than 1 then
set stuffDropped to get every file of thisItem as alias list
else if countEachFile is equal to 1 then
set stuffDropped to get every file of thisItem as alias as list
else – countEachFile is 0
exit repeat
end if
else
set stuffDropped to thisItem as list
end if
end tell

repeat with thisFile in stuffDropped
tell application “Adobe Photoshop 7.0”
activate
open thisFile showing dialogs never
set myOptions to {class:EPS save options, encoding:maximum quality JPEG, embed color profile:true, preview type:JPEG Mac OS}
– Run Photoshop action to USM, convert to CMYK
– do action “Action 1 (AutoLevels)” from “Guido Actions”
save current document as Photoshop EPS ¬
with options myOptions in file (thisFile as string) appending lowercase extension
close current document saving no
end tell
end repeat

Tried adding the following but it does not work

tell application “Finder”
delete (items of this_folder whose name is in {“.jpg”})
end tell

end repeat
end open

Anybody have an idea how to clean up the “old” files once they are converted?
Much help would be appreciated. Thanks J

[/quote]