[X4U] Simple Open code for Applescript
Bill White
billwhite at mac.com
Fri Oct 7 01:27:34 PDT 2005
On 10/7/05 12:41 AM, Brett Conlon/HU/Music-AU/SONY
<brett.conlon at SonyDADC.com> wrote:
> Any AppleScript boffins out there?
Yep! :-)
> I'm writing a basic AppleScript droplet for a Photoshop CS action. The
> operator will drop a file on the droplet, Photoshop will open the file and run
> the action.... and maybe I'll have it do a few things before or after the
> action too.
>
> Everything is set up OK but I need the basic code for the "Open" part.
> Sometimes the file may be a PSD or it may be a PDF
The way to do this is to have the Finder open the file using Photoshop's
file ID, which isn't exactly intuitive!
Here's the open handler you'd use for the droplet:
on open theseFiles
repeat with aFile in theseFiles
tell application "Finder" to open aFile using application file id
"8BIM" -- this should be on one line
tell application "Adobe Photoshop CS"
-- do your Photoshop stuff in here
end tell
end repeat
end open
You could also tack on a run handler so that if the user double-clicks the
droplet it will ask for a file to process, and to simplify things spin the
Photoshop part into its own handler....something like this:
on run
set aFile to choose file with prompt "Choose a file to process"
doPhotoshopStuff(aFile)
end run
on open theseFiles
repeat with aFile in theseFiles
doPhotoshopStuff(aFile)
end repeat
end open
on doPhotoshopStuff(thisFile)
tell application "Finder" to open thisFile using application file id
"8BIM" -- this should be on one line
tell application "Adobe Photoshop CS"
-- do your Photoshop stuff in here
end tell
end doPhotoshopStuff
HTH,
-- Bill
More information about the X4U
mailing list