Applescript / Javascript > Adobe Photoshop scripting

Can't get my script running

(1/3) > >>

Jean-Marie Schwartz:
Hi All,

Here is a script I'm trying to set to save Tiff files with LZW compression:

--- Quote ---set TheseItems to choose file with prompt "Choisir les fichiers" with multiple selections allowed without invisibles

--on open TheseItems
tell application "Adobe Photoshop CS"
     activate
     set TiffOptions to {class:TIFF save options, embed color profile:true, image compression:LZW}
     repeat with ThisItem in TheseItems
          try
               open ThisItem
               delay 1
               save current document in file ThisItem as TIFF with options TiffOptions appending lowercase extension without copying
               close current document without saving
          on error error_message number error_number
               if the error_number is not -128 then
                    tell application "Finder"
                         activate
                         display dialog error_message buttons {"Cancel"} default button 1 giving up after 120
                    end tell
               end if
          end try
     end repeat
end tell
--end open
--- End quote ---

But I get an error "Can't make some data into the expected type".

Why that? And above all how to fix it?
Thanks for your help!

BTW it smells like holidays around here, doesn't it?  8)

Publi-Script:
Hi Jean-Marie,

Simply remove the word "file" from your "save" line and you should now have an uncle named Bob! ;-)

That line should be:
save current document in ThisItem as TIFF with options TiffOptions appending lowercase extension without copying

HTH

larsen67:
Holidays!!! at 5.30 off home for a 2 week break. No moneys to go anywhere so some software learning and still sticking my head in other people's business here and on a couple of other forums.

Jean-Marie Schwartz:
Is that that simple?  :-\
I shall give it a shot later on. Thanks in advance for I'm pretty sure it'll work  :)

I remember before leaving on Friday I discovered a shell named tiffutil. I tried this: tiffutil -lzw "13 procession.tif" -out "13 procession.tif" which was working neat from Terminal. I'd have now to make it work more widely from AS (I encountered the same issue as a while back when a full path would not be recognized  :'( ).

I'll be back with my final result of script.

Thanks again, Michel. When the solution is so simple I really feel like a newbie. That is probably what I am actually.

Jean-Marie Schwartz:
I'm back with an issue I encountered some months ago but wasn't able to fix so far: shell command is not working.
Here is the code I have so far:

--- Quote ---set TheseItems to choose file with prompt "Choisir les fichiers" with multiple selections allowed without invisibles

set FileOnePath to (first item of TheseItems) as text
set ASTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to ":"
set ParentPath to text items 1 thru -2 of FileOnePath as string
set AppleScript's text item delimiters to ASTID
set FolderPath to (POSIX path of ParentPath) as string
set ChangeDirectoryShell to ("cd \"" & FolderPath & "/\"") as string

repeat with ThisItem in TheseItems
     set FileName to (name of (info for ThisItem)) as string
     set TheShellScript to ""
     set TheShellScript to ("tiffutil -lzw '" & FileName & "' -out '" & FileName & "'") as text
     do shell script (ChangeDirectoryShell)
     do shell script (TheShellScript)
end repeat
--- End quote ---

The error returned says unable to open file [FileName] when through Terminal there is no problem. Any idea why? And how to fix it? (I wonder if spaces in the file name is not a problem but I'm not sure.)

EDIT: I've tried simply passing files path straight to the shell command (do shell script "tiffutil -lzw " & (quoted form of POSIX path of ThisItem) & " -out " & (quoted form of POSIX path of ThisItem)". This works OK when I put files at the User level but it would error when files are in sub-folders  :'( At least the idea behind my script is good  :)
So what could prevent the shell command to perform correctly?

Navigation

[0] Message Index

[#] Next page

Go to full version