Opening files in Photoshop with an applescript droplet - applescript

I have a problem. I am a complete Applescript novice and I am trying to simply open 3 files from my desktop into Photoshop CS4 using a droplet, but when I drop the files I get This error:
Can't get alias "Macintosh HD:Users:nazkav:Desktop:Kav1_jpg"
This is the code I'm using:
on open these_files
repeat with i from 1 to the count of these_files
set this_file to item i of these_files
my image(this_file)
end repeat
end open
on image(the_image)
tell application "Adobe Photoshop CS4"
activate
open the_image as JPEG
end tell
end image
I hope somebody can help
Thanks in advance
Kavin

Related

How could I use applescript to play keynote slids?

everyone
I try to use applescript to play my keynote slid,but occure error
set thisFile to "/Users/usrname/Desktop/cardtest.key"
tell application "Keynote"
activate
open thisFile
start thisFile from the first slide of thisFile
end tell
this code will open keynote file successfully,but can't run slids.
the error was keynote error : can't make "path" become type "document".
I tried to use:
tell slideshow 1
but another error: slideshow should be the end of sentence, should not have 1.
have no idea why.
You are going to start a POSIX path rather than a Keynote document.
This is exactly what the error is telling you.
You have to use the reference to the opened document
set thisFile to "/Users/usrname/Desktop/cardtest.key"
tell application "Keynote"
activate
set currentDocument to open thisFile
tell currentDocument to start from first slide
end tell

Open Photoshop file in same directory as AppleScript

I am trying to automate label generation from MS Excel into Photoshop using AppleScript. I can get all the data from Excel just fine, however getting that data into a predefined Photoshop document causes problems.
Specifically, I am unable to get Photoshop to open the template file which is located in the same folder as the AppleScript itself. I have tried numerous ways, including using a tell finderblock like this
tell application "Finder"
set myFolder to container of (path to me) as text
end tell
set template_path to myFolder & "CC.psd"
tell application "Adobe Photoshop"
open template_path
end tell
What sort of magic do I need to perform?
PS: Currently this is running on my local drive, however it would be awesome if it would work on network volumes as well.
Thank you
Tobias Timpe

AppleScript: open current iTunes track in another program [Riffstation]

I'm new to AppleScript and not programmer, so I'm hoping someone can help me out...
I want to get the current track path in iTunes and open the file in another program [Riffstation]
seems like this should work, but it doesn't:
tell application "iTunes"
set songLocation to get location of current track
end tell
tell application "Riffstation"
open songLocation
end tell
any help would be greatly appreciated!!!
Riffstation doesn't support AppleScript so you have to ask the Finder to open the file and pass it to Riffstation
tell application "iTunes"
set songLocation to get location of current track
end tell
tell application "Finder" to open songLocation using application file id "com.SonicLadder.Riffstation"
If you want to ignore .m4p files use
tell application "iTunes" to set {location:songLocation, kind:songKind} to current track
if songKind is not "Protected AAC audio file" then
tell application "Finder" to open songLocation using application file id "com.SonicLadder.Riffstation"
end if

Applescript simple open save file snippet?

I just need a snippet to open and then save a file. It's an illustrator PDF with linked artwork, problem being the linked files do not update unless I open then save the file and I am having to do this sooooo many times it's making my brain explode.
Should be straightforward. I tested the following snippet in Illustrator CS3 (13.0.2) on Mac OS X 10.6.8.
set theFiles to choose file with prompt "Select the files" of type {"pdf"} with multiple selections allowed
tell application "Adobe Illustrator"
repeat with theFile in theFiles
open theFile without dialogs
save current document in theFile as pdf
end repeat
end tell
The choose file command (which prompts the user to locate one or more files) is just one way of obtaining a list of files. You could just as well use
tell app "Finder" to set theFiles to every document file of folder "Macintosh HD:Full:Path:To:Your:Folder" whose file type begins with "pdf"
if you want to get all PDF files inside a specific folder.

How can I get the currently open file's path in photoshop (cs5) with applescript?

How can I get the currently open file's path in photoshop (cs5) with applescript?
I'm using CS5 on Mac OSX 10.7
I've tried the answer below and it gives the following error in the Applescript Editor:
error "Adobe Photoshop CS5 got an error: Can’t get document 1.
Invalid index." number -1719 from document 1
UPDATE: I have tested the code below in CS5 and Mac OS 10.7 and can confirm that this works even with a simple switch of tell application "Adobe Photoshop CS4" to tell application "Adobe Photoshop CS5". The error that you are getting is the result of there either not being a document open in the first place since you are targeting document 1. You can easily check for this with the following:
tell application "Adobe Photoshop CS5"
set documentCount to count documents
if documentCount > 0 then
set theDocument to document 1
set theFilePath to file path of theDocument
return theFilePath
else
-- no documents open. what to do?
end if
end tell
OLD ANSWER: I don't have CS5 (yet), but here it is for CS4, and I imagine CS5's version won't be too different, if at all, since Adobe has done a good job normalizing the API since CS3:
tell application "Adobe Photoshop CS4"
set theDocument to document 1
set theFilePath to file path of theDocument
return theFilePath
end tell
--> Result: Macintosh HD:path:to:file:filename.ext

Resources