• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Changes to Photoshop CS5 and Applescript

Explorer ,
May 06, 2010 May 06, 2010

Copy link to clipboard

Copied

Looks like there are some major Applescript changes to CS5, which is unwelcome for anyone with existing scripts. From what I can see, the difference (that affect me anyway) are

a) PSCS5 seems to dislike referring to files with "as alias" and removing this from my scripts helps them to work, whereas other apps need it, as did previous

b) apparently script support for referring to the currently document has changed. "if visible layer of current document is true then..." no longer works, nor do document 0, document 1, etc. Anyone know how to refer to the current document?

c) support for history doesn't seem to be there anymore. I cannot seem to use AS commands like, "set myState to history states as list" or "set current history state to history state newState" were awesome for my workflow, but are they impossible to achieve now?

d) One more. The important "set docref to make new document with properties {height: 150, width: 150}" is also broken. How would one make a new document in Applescript?

TOPICS
Actions and scripting

Views

32.4K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Adobe Employee ,
May 13, 2010 May 13, 2010

Copy link to clipboard

Copied

Could you give me an example of what kind of problem you encountered?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 14, 2010 May 14, 2010

Copy link to clipboard

Copied

Try this:

tell application "Adobe Photoshop CS4"

set psDocRef to front document

end tell

and then try this:

tell application "Adobe Photoshop CS5"

set psDocRef to front document

end tell

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
May 14, 2010 May 14, 2010

Copy link to clipboard

Copied

For AppleScript, you could use "current" to set focus to the frontmost object. So, you could change the focus by using "current" as follows:

tell application "Adobe Photoshop CS5"

    activate

    set psDocRef to make new document -- first document has the focus

    make new document -- now, second document has the focus

    set current document to psDocRef -- the first document get the focus again.

end tell

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 16, 2010 May 16, 2010

Copy link to clipboard

Copied

Ah—making sure to launch Photoshop CS5 before AppleScript Editor (or Xcode) does seem to fix the problems for me. The dictionary shows up correctly, and the compiling errors are gone. Thank you!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
May 17, 2010 May 17, 2010

Copy link to clipboard

Copied

This sounds like an issue where the Photoshop terminology gets dropped on the floor because Cocoa installs its own terminology handler on top of Photoshop's handler.

If I follow the steps described in this thread, then I do not see the problem on my machine.

My test case is:

- Launch the AppleScript Editor

- Enter:

tell application "Adobe Photoshop CS5"

make new document

filter current layer of the current document using lens blur with options {class:lens blur, radius:13}

end tell

- Click compile (or hit enter)

Photoshop launches and the script compiles correctly

There could be some OS version sensitivity here. I am currently testing on 10.6.3.

Could you let me know which version of OSX that you are using?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 16, 2010 May 16, 2010

Copy link to clipboard

Copied

AppleScript support is effectively broken.

We have compiled scripts which fail to execute properly. Once this happens, every AppleScript command then fails including trying to compile new commands using the script editor (the 'current document' error mentioned above).

This breaks our application which was working great for years on CS3 and CS4.

Can we expect Adobe to fix this in a minor update of PS CS5?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 31, 2010 May 31, 2010

Copy link to clipboard

Copied

I just installed PS CS5 and am unable to use my old applescript app for the reasons given above. I stupidly scrapped the former Photoshop (CS2) and am unable to reinstall it so I am really stuck. I tried editing the AS code and I could run it in XCode in debug mode but the syntax colour wouldn't show. The text remained black for new typing. Very strange. Other AS apps not involving CS5 still worked as expected.

Upon an error state I found that the Photoshop app had lost its Dictionary. (Applescript Editor came up blank.) Restarting Photoshop fixed this.

After much frustration I found this thread. Thanks. Please email the CS5 fix to mikey666*****at*****shaw*****dot*****ca.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 01, 2010 Jun 01, 2010

Copy link to clipboard

Copied

Thanks for the prompt reply.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 10, 2010 Jun 10, 2010

Copy link to clipboard

Copied

I have a somewhat complex script that is performing a repeat and I don't understand why CS5 is broken on it.

tell application "Finder"
    -- make an item list from your identified folder
    set itemList to files in raw_folder
end tell

-- create a repeat that takes each file from the item list and do something
repeat with i from 1 to count of items of itemList
    tell application "Finder"
        set fileName to item i of itemList as alias
        --set itemPath to raw_folder & fileName
    end tell

    tell application "Adobe Photoshop CS5"
        set display dialogs to never
       
        activate
        open fileName

ScriptDebugger is reporting at this point the script starts. I have tried changing the last line to

open alias fileName but it still stops.

Is there really broken script communication between PSCS5 and OSX?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Jun 10, 2010 Jun 10, 2010

Copy link to clipboard

Copied

This is an example of dealing with the alias problem:

set appFolder to path to applications folder as string
set myPath to appFolder & "Adobe Photoshop CS5:Samples:"
tell application "Finder" to set fileList to name of files of folder myPath
set fileNum to count items of fileList

tell application "Adobe Photoshop CS5"
    activate
    set display dialogs to never
    repeat with i from 1 to fileNum
        open alias (myPath & item i of fileList)
    end repeat
end tell

The key is to coerce/cast the alias as "string" then in Photoshop coercing/casting it back to alias.

In your example, if you change the following lines, it should work for you:

In Finder:

set fileName to item i of itemList as alias => set fileName to (item i of itemList) as string

in Photoshop:

open fileName => open alias fileName

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 10, 2010 Jun 10, 2010

Copy link to clipboard

Copied

Thank you so much!


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 07, 2011 Sep 07, 2011

Copy link to clipboard

Copied

Hey JonLo.  I have a serious issue.  I've gone through endless forums and I'm either too thick to comprehend my issue or there's a serious scripting bug.  I want to open a dynamic filepath.  For instance, it will be at Users:folder:folder1 once, but accessed in a differnet folder the next time. Script:

tell application "Finder"

set locationLogoPackage to (choose folder with prompt "Please locate your LOGO PACKAGE folder") as alias

set folderPrimary to make new folder at locationLogoPackage with properties {name:"Primary"}

set folderPDF to make new folder at folderPrimary with properties {name:"pdf"}

set folderTIF to make new folder at folderPrimary with properties {name:"tif"}

set folderPDF to (folderPDF) as alias

set folderTIF to (folderTIF) as alias

tell "Finder"

set filePDF to files in folderPDF

set filePDF to (filePDF) as string

end tell

tell application "Adobe Photoshop CS5"

open alias filePDF

save current document in (folderTIF) as TIFF without options

close current document saving no

end tell

however it works with a definite file path =(...

tell application "Finder"

set locationLogoPackage to (choose folder with prompt "Please locate your LOGO PACKAGE folder") as alias

set folderPrimary to make new folder at locationLogoPackage with properties {name:"Primary"}

set folderPDF to make new folder at folderPrimary with properties {name:"pdf"}

set folderTIF to make new folder at folderPrimary with properties {name:"tif"}

set folderPDF to (folderPDF) as alias

set folderTIF to (folderTIF) as alias

tell application "Finder"

set filePDF to "500gig:Users:wyatt:Desktop:logo_package:Primary:pdf:testAi.pdf" as string

end tell

tell application "Adobe Photoshop CS5"

open alias filePDF

save current document in ("500gig:Users:user1:Desktop:logo_package:Primary:tif") as TIFF without options

close current document saving no

end tell

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Sep 09, 2011 Sep 09, 2011

Copy link to clipboard

Copied

Hi there,

I think your example of definite file path is correct. So the problem is how to get a list of files into a list of strings.

Under Finder, you

     set filePDF to files in folderPDF     -- you get a list of files (file object)

     set filePDF to (filePDF) as string     -- you get a single string of the list of files you got from previous line

So, how can you get a list of strings?

     set myFolder to folderPDF as string     -- you get the path to your PDF folder as string

     set tifFolder to folderTIF as string          -- you get the path to your TIF folder as string

     tell application "Finder"

          set fileList to name of files of folderPDF     -- you get every filename in that folder which is text/string

     end tell

     repeat with filename in fileList

          set myFile to myFolder & filename          -- now you get the full path to the file as string

          -- then you could treat it like a single file

          tell application "Adobe Photoshop CS5"

               open alias myFile

               save current document in (tifFolder) as TIFF without options

               close current document saving no

          end tell

     end repeat

Let me know if you hit any problem.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 19, 2011 Dec 19, 2011

Copy link to clipboard

Copied

Hi,

I have a similar issue, but cannot seem to get my script to work using the Photoshop CS5 trial version. Here is the script for Photoshop CS3, which works. Any help would be appreciated.

Thanks.

Ryan (sherman@enasco.com)

with timeout of 10000 seconds

          tell application "Finder"

  --select folder to run proofs on

  activate

                    set finalPDFsFolder to choose folder with prompt "Select Final PDF's folder"

                    set folPath to finalPDFsFolder as text

  --list contents of selected folder

                    set folList to list folder finalPDFsFolder without invisibles

                    display dialog "Import version file as CMYK or Grayscale?" buttons {"CMYK", "grayscale"}

                    set theMode to button returned in the result

  --if contents don't contain "Regular Version" folder and "Version Proofs" folder and at least one other folder then error

  (*repeat with a in folList

                              set tempFile to (folPath & a) as alias

                              if file type of tempFile is not "fold" then

                                        error "The Folder you have selected is not set up properly, this script will end. Bonehead!"

                              end if

                    end repeat*)

                    if (count of folList) < 3 then

                              error "The Folder you have selected is not set up properly, this script will end. Bonehead!"

                    end if

                    set tempfolList to {}

                    repeat with y in folList

                              set y to y as string

                              copy y to end of tempfolList

                    end repeat

                    if tempfolList does not contain "Approved Regular Version" and tempfolList does not contain "Version Proofs" then

                              error "The Folder you have selected is not set up properly, this script will end. Bonehead!"

                    end if

 

  --set up paths to regular and version proof folders

                    set regVerFol to (folPath & "Approved Regular Version") as alias

                    set regVerPath to regVerFol as text

                    set verProofsFol to (folPath & "Version Proofs") as alias

                    set verProofsPath to verProofsFol as text

 

  --list contents of "Approved Regular Version" folder

                    set regVerList to list folder regVerFol

                    set theList to regVerList

                    set sortedList to my quickSort(theList)

                    set regVerList to sortedList

 

  --make a list of root names of regular version files

                    set RegVerRoots to {}

                    repeat with j in regVerList

                              set oldDelim to AppleScript's text item delimiters

                              set AppleScript's text item delimiters to "."

                              set jRoot to text item 1 of j

                              set AppleScript's text item delimiters to oldDelim

                              copy jRoot to the end of RegVerRoots

                    end repeat

 

  --list contents of "Version Proofs" folder

                    set verProofsList to list folder verProofsFol

                    set theList to verProofsList

                    set sortedList to my quickSort(theList)

                    set verProofsList to sortedList

 

 

  --make a list of the other folders

                    set verFolList to {}

                    repeat with x in folList

                              set x to x as string

                              if x is not "Regular Version" and x is not "Version Proofs" and x is not "Approved Regular Version" then

                                        copy x to the end of verFolList

                              end if

                    end repeat

 

  --list contents of other folders through repeat statement(s)

  --compare contents of Approved Regular Version folder to contents of other folder

  --if there's a match set the two files as a pair and slap them in a list

                    set filePairsList to {}

                    repeat with z in verFolList

                              set zFol to (folPath & z) as alias

                              set zFolPath to zFol as text

                              set zFolList to list folder zFol

                              set theList to zFolList

                              set sortedList to my quickSort(theList)

                              set zFolList to sortedList

 

                              set zFiles to {}

                              repeat with zz in zFolList

                                        set zzz to (zFolPath & zz) as alias

                                        copy zzz to the end of zFiles

                              end repeat

 

                              repeat with i in zFiles

                                        set zName to name of i

                                        set oldDelim to AppleScript's text item delimiters

                                        set AppleScript's text item delimiters to "_"

                                        set zRoot to text item 1 of zName

                                        set AppleScript's text item delimiters to oldDelim

 

                                        if RegVerRoots contains zRoot then

                                                  set jFileName to zRoot & ".pdf"

                                                  set j to (regVerPath & jFileName) as alias

                                                  set i to i as alias

                                                  set pairList to {j, i}

                                                  copy pairList to the end of filePairsList

                                        end if

                              end repeat

                    end repeat

 

  --if Version Proofs is empty merge files in filePairsList

                    if verProofsList is {} then

                              repeat with v in filePairsList

                                        set regFile to item 1 of v

                                        set verFile to item 2 of v

                                        set doc1 to name of regFile

                                        set doc2 to name of verFile

                                        my mergeFiles(regFile, verFile, doc1, doc2, verProofsFol)

                              end repeat

                    else

                              set verProofsRootList to {}

                              repeat with q in verProofsList

                                        set oldDelim to AppleScript's text item delimiters

                                        set AppleScript's text item delimiters to "_"

                                        set qRoot to text item 1 of q

                                        set AppleScript's text item delimiters to oldDelim

                                        copy qRoot to the end of verProofsRootList

                              end repeat

                    end if

  --compare files in pair list to files in "Version Proofs"

                    set finalPairsList to {}

                    repeat with n in filePairsList

                              set regFile to item 1 of n

                              set regFileName to name of regFile

                              set suffixFile to item 2 of n

                              set suffixFileName to name of suffixFile as string

  (*set offset1 to offset of "_" in suffixFileName

                              set offset2 to (offset of "." in suffixFileName) - 1

                              set theString to ""

                              set theSuffix to characters offset1 thru offset2 of suffixFileName

                              repeat with i in theSuffix

                                        set theString to theString & i

                              end repeat

                              set oldDelim to AppleScript's text item delimiters

                              set AppleScript's text item delimiters to "."

                              set regFileRoot to text item 1 of regFileName

                              set AppleScript's text item delimiters to oldDelim*)

                              if verProofsList contains suffixFileName then

                                        set modDate2 to modification date of item 2 of n

                                        set verFile to suffixFile

                                        set verModDate to modification date of verFile

                                        if (modDate2 > verModDate) then

                                                  set n to n as list

                                                  copy n to the end of finalPairsList

                                        end if

                              else

                                        set n to n as list

                                        copy n to the end of finalPairsList

                              end if

                    end repeat

 

                    repeat with v in finalPairsList

                              set regFile to item 1 of v

                              set verFile to item 2 of v

                              set doc1 to name of regFile

                              set doc2 to name of verFile

                              my mergeFiles(regFile, verFile, doc1, doc2, verProofsFol, theMode)

                    end repeat

  activate

                    display dialog "Script is complete. Please verify that the Version Proofs were saved correctly. Have a nice day!" giving up after 5

          end tell

end timeout

on quickSort(theList)

          set lesserList to {}

          set greaterList to {}

          try

                    set thePivot to theList's first item

                    repeat with eachItem in theList's rest

                              if eachItem's contents is less than thePivot then

                                        set lesserList's end to eachItem's contents

                              else

                                        set greaterList's end to eachItem's contents

                              end if

                    end repeat

                    if lesserList is not {} then set lesserList to quickSort(lesserList)

                    if greaterList is not {} then set greaterList to quickSort(greaterList)

                    return lesserList & thePivot & greaterList

          on error

                    return ""

          end try

end quickSort

on mergeFiles(regFile, verFile, doc1, doc2, verProofsFol, theMode)

          tell application "Finder"

                    set verFileName to name of verFile & ".pdf"

                    set oldDelim to AppleScript's text item delimiters

                    set AppleScript's text item delimiters to "."

                    set verFileRoot to text item 1 of verFileName as string

                    set AppleScript's text item delimiters to oldDelim

                    set vpFileName to ((verProofsFol) & verFileRoot & "VP.pdf") as string

          end tell

          tell application "Adobe Photoshop CS3"

                    set regOptions to {class:PDF open options, name:doc1, resolution:300, mode:CMYK, crop page:media box}

                    set saveOptions to {class:PDF save options, encoding:ZIP, embed color profile:false, PDF compatibility:PDF 13, PDF standard:PDFX1a2001 standard, preserve editing:false}

  activate

  open regFile as PDF with options regOptions

  flatten document doc1

                    set theHeight to height of document doc1

                    set theWidth to width of document doc1

                    set splitList to split channels document doc1

                    set blackPlate to item 4 of splitList

  close blackPlate saving no

                    if theMode is not "grayscale" then

                              set verOptions to {class:PDF open options, name:doc2, resolution:300, mode:CMYK, crop page:media box}

  open verFile as PDF with options verOptions

  flatten document doc2

                              set splitList2 to split channels document doc2

                              set cyanPlate2 to item 1 of splitList2

                              set magPlate2 to item 2 of splitList2

                              set yellowPlate2 to item 3 of splitList2

  close cyanPlate2 saving no

  close magPlate2 saving no

  close yellowPlate2 saving no

                    else

                              set verOptions to {class:PDF open options, mode:grayscale, resolution:300}

  open verFile as PDF with options verOptions

  flatten document doc2

                    end if

                    set newDocProperties to {height:theHeight, width:theWidth, mode:CMYK, resolution:300, initial fill:white, color profile kind:none}

  make new document with properties newDocProperties

                    do action "Merge Files" from "Nasco Prepress"

  save document 1 in vpFileName as Photoshop PDF with options saveOptions appending lowercase extension without copying

  close document 1 saving no

  purge clipboard cache

          end tell

end mergeFiles

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Dec 19, 2011 Dec 19, 2011

Copy link to clipboard

Copied

Ryan, I don't have all this folder structure and files for me to check your script… However the issue with CS5 & Photoshop is it now likes to be passed strings of file paths rather than finder's alias file specifiers… so at a quick overview I can see you copy i & j as a list pair of aliases to another list filePairsList you later pass these as arguments to your mergeFiles sub-routine… Make items i & j strings instead… and hopefully that should do you…

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 19, 2011 Dec 19, 2011

Copy link to clipboard

Copied

Thanks for the info Mark. Can you specify exactly which statements in the script to change to strings? I certainly appreciate your help. If you have time to look at this, I can send you the file structure and files. You can email me at sherman@enasco.com and I will forward you the information.

Thanks.

Ryan

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Dec 19, 2011 Dec 19, 2011

Copy link to clipboard

Copied

I just quickly made the 2 suggested edits where I think your issue may be… Also changed CS3 to CS5 in the sub…

with timeout of 10000 seconds

          tell application "Finder"

  --select folder to run proofs on

  activate

                    set finalPDFsFolder to choose folder with prompt "Select Final PDF's folder"

                    set folPath to finalPDFsFolder as text

  --list contents of selected folder

                    set folList to list folder finalPDFsFolder without invisibles

                    display dialog "Import version file as CMYK or Grayscale?" buttons {"CMYK", "grayscale"}

                    set theMode to button returned in the result

  --if contents don't contain "Regular Version" folder and "Version Proofs" folder and at least one other folder then error

  (*repeat with a in folList

                              set tempFile to (folPath & a) as alias

                              if file type of tempFile is not "fold" then

                                        error "The Folder you have selected is not set up properly, this script will end. Bonehead!"

                              end if

                    end repeat*)

                    if (count of folList) < 3 then

                              error "The Folder you have selected is not set up properly, this script will end. Bonehead!"

                    end if

                    set tempfolList to {}

                    repeat with y in folList

                              set y to y as string

                              copy y to end of tempfolList

                    end repeat

                    if tempfolList does not contain "Approved Regular Version" and tempfolList does not contain "Version Proofs" then

                              error "The Folder you have selected is not set up properly, this script will end. Bonehead!"

                    end if

 

  --set up paths to regular and version proof folders

                    set regVerFol to (folPath & "Approved Regular Version") as alias

                    set regVerPath to regVerFol as text

                    set verProofsFol to (folPath & "Version Proofs") as alias

                    set verProofsPath to verProofsFol as text

 

  --list contents of "Approved Regular Version" folder

                    set regVerList to list folder regVerFol

                    set theList to regVerList

                    set sortedList to my quickSort(theList)

                    set regVerList to sortedList

 

  --make a list of root names of regular version files

                    set RegVerRoots to {}

                    repeat with j in regVerList

                              set oldDelim to AppleScript's text item delimiters

                              set AppleScript's text item delimiters to "."

                              set jRoot to text item 1 of j

                              set AppleScript's text item delimiters to oldDelim

                              copy jRoot to the end of RegVerRoots

                    end repeat

 

  --list contents of "Version Proofs" folder

                    set verProofsList to list folder verProofsFol

                    set theList to verProofsList

                    set sortedList to my quickSort(theList)

                    set verProofsList to sortedList

 

 

  --make a list of the other folders

                    set verFolList to {}

                    repeat with x in folList

                              set x to x as string

                              if x is not "Regular Version" and x is not "Version Proofs" and x is not "Approved Regular Version" then

                                        copy x to the end of verFolList

                              end if

                    end repeat

 

  --list contents of other folders through repeat statement(s)

  --compare contents of Approved Regular Version folder to contents of other folder

  --if there's a match set the two files as a pair and slap them in a list

                    set filePairsList to {}

                    repeat with z in verFolList

                              set zFol to (folPath & z) as alias

                              set zFolPath to zFol as text

                              set zFolList to list folder zFol

                              set theList to zFolList

                              set sortedList to my quickSort(theList)

                              set zFolList to sortedList

 

                              set zFiles to {}

                              repeat with zz in zFolList

                                        set zzz to (zFolPath & zz) as alias

                                        copy zzz to the end of zFiles

                              end repeat

 

                              repeat with i in zFiles

                                        set zName to name of i

                                        set oldDelim to AppleScript's text item delimiters

                                        set AppleScript's text item delimiters to "_"

                                        set zRoot to text item 1 of zName

                                        set AppleScript's text item delimiters to oldDelim

 

                                        if RegVerRoots contains zRoot then

                                                  set jFileName to zRoot & ".pdf"

                                                  set j to (regVerPath & jFileName) as text

                                                  set i to i as text

                                                  set pairList to {j, i}

                                                  copy pairList to the end of filePairsList

                                        end if

                              end repeat

                    end repeat

 

  --if Version Proofs is empty merge files in filePairsList

                    if verProofsList is {} then

                              repeat with v in filePairsList

                                        set regFile to item 1 of v

                                        set verFile to item 2 of v

                                        set doc1 to name of regFile

                                        set doc2 to name of verFile

                                        my mergeFiles(regFile, verFile, doc1, doc2, verProofsFol)

                              end repeat

                    else

                              set verProofsRootList to {}

                              repeat with q in verProofsList

                                        set oldDelim to AppleScript's text item delimiters

                                        set AppleScript's text item delimiters to "_"

                                        set qRoot to text item 1 of q

                                        set AppleScript's text item delimiters to oldDelim

                                        copy qRoot to the end of verProofsRootList

                              end repeat

                    end if

  --compare files in pair list to files in "Version Proofs"

                    set finalPairsList to {}

                    repeat with n in filePairsList

                              set regFile to item 1 of n

                              set regFileName to name of regFile

                              set suffixFile to item 2 of n

                              set suffixFileName to name of suffixFile as string

  (*set offset1 to offset of "_" in suffixFileName

                              set offset2 to (offset of "." in suffixFileName) - 1

                              set theString to ""

                              set theSuffix to characters offset1 thru offset2 of suffixFileName

                              repeat with i in theSuffix

                                        set theString to theString & i

                              end repeat

                              set oldDelim to AppleScript's text item delimiters

                              set AppleScript's text item delimiters to "."

                              set regFileRoot to text item 1 of regFileName

                              set AppleScript's text item delimiters to oldDelim*)

                              if verProofsList contains suffixFileName then

                                        set modDate2 to modification date of item 2 of n

                                        set verFile to suffixFile

                                        set verModDate to modification date of verFile

                                        if (modDate2 > verModDate) then

                                                  set n to n as list

                                                  copy n to the end of finalPairsList

                                        end if

                              else

                                        set n to n as list

                                        copy n to the end of finalPairsList

                              end if

                    end repeat

 

                    repeat with v in finalPairsList

                              set regFile to item 1 of v

                              set verFile to item 2 of v

                              set doc1 to name of regFile

                              set doc2 to name of verFile

                              my mergeFiles(regFile, verFile, doc1, doc2, verProofsFol, theMode)

                    end repeat

  activate

                    display dialog "Script is complete. Please verify that the Version Proofs were saved correctly. Have a nice day!" giving up after 5

          end tell

end timeout

on quickSort(theList)

          set lesserList to {}

          set greaterList to {}

          try

                    set thePivot to theList's first item

                    repeat with eachItem in theList's rest

                              if eachItem's contents is less than thePivot then

                                        set lesserList's end to eachItem's contents

                              else

                                        set greaterList's end to eachItem's contents

                              end if

                    end repeat

                    if lesserList is not {} then set lesserList to quickSort(lesserList)

                    if greaterList is not {} then set greaterList to quickSort(greaterList)

                    return lesserList & thePivot & greaterList

          on error

                    return ""

          end try

end quickSort

on mergeFiles(regFile, verFile, doc1, doc2, verProofsFol, theMode)

          tell application "Finder"

                    set verFileName to name of verFile & ".pdf"

                    set oldDelim to AppleScript's text item delimiters

                    set AppleScript's text item delimiters to "."

                    set verFileRoot to text item 1 of verFileName as string

                    set AppleScript's text item delimiters to oldDelim

                    set vpFileName to ((verProofsFol) & verFileRoot & "VP.pdf") as string

          end tell

          tell application "Adobe Photoshop CS5"

                    set regOptions to {class:PDF open options, name:doc1, resolution:300, mode:CMYK, crop page:media box}

                    set saveOptions to {class:PDF save options, encoding:ZIP, embed color profile:false, PDF compatibility:PDF 13, PDF standard:PDFX1a2001 standard, preserve editing:false}

  activate

  open regFile as PDF with options regOptions

  flatten document doc1

                    set theHeight to height of document doc1

                    set theWidth to width of document doc1

                    set splitList to split channels document doc1

                    set blackPlate to item 4 of splitList

  close blackPlate saving no

                    if theMode is not "grayscale" then

                              set verOptions to {class:PDF open options, name:doc2, resolution:300, mode:CMYK, crop page:media box}

  open verFile as PDF with options verOptions

  flatten document doc2

                              set splitList2 to split channels document doc2

                              set cyanPlate2 to item 1 of splitList2

                              set magPlate2 to item 2 of splitList2

                              set yellowPlate2 to item 3 of splitList2

  close cyanPlate2 saving no

  close magPlate2 saving no

  close yellowPlate2 saving no

                    else

                              set verOptions to {class:PDF open options, mode:grayscale, resolution:300}

  open verFile as PDF with options verOptions

  flatten document doc2

                    end if

                    set newDocProperties to {height:theHeight, width:theWidth, mode:CMYK, resolution:300, initial fill:white, color profile kind:none}

  make new document with properties newDocProperties

                    do action "Merge Files" from "Nasco Prepress"

  save document 1 in vpFileName as Photoshop PDF with options saveOptions appending lowercase extension without copying

  close document 1 saving no

  purge clipboard cache

          end tell

end mergeFiles

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 20, 2011 Dec 20, 2011

Copy link to clipboard

Copied

Hi Mark,

Thanks for the edits. Applescript now receives an error:

Can't get name of "Macintosh HD:Users:ryansherman:Desktop:Final PDF Files:Approved Regular Version:12PEp007.pdf".

set regFileName to name of regFile  = this is the culprit in the script.

Any suggestion to fix this?

Thanks.

Ryan

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 20, 2011 Dec 20, 2011

Copy link to clipboard

Copied

Hi Mark,

I did some testing on this, and found out I needed to "set regFile to regFile as string" through the Finder and then "open file regFile as PDF with options regOptions" in Photoshop CS5. Thanks again for all your help!! I appreciate it.

Ryan

tell application "Adobe Photoshop CS5"

                    set regOptions to {class:PDF open options, name:doc1, resolution:300, mode:CMYK, crop page:media box}

                    set saveOptions to {class:PDF save options, encoding:ZIP, embed color profile:false, PDF compatibility:PDF 13, PDF standard:PDFX1a2001 standard, preserve editing:false}

  activate

                    tell application "Finder"

                              set regFile to regFile as string

                    end tell

  open file regFile as PDF with options regOptions

  flatten document doc1

                    set theHeight to height of document doc1

                    set theWidth to width of document doc1

                    set splitList to split channels document doc1

                    set blackPlate to item 4 of splitList

  close blackPlate saving no

                    if theMode is not "grayscale" then

                              set verOptions to {class:PDF open options, name:doc2, resolution:300, mode:CMYK, crop page:media box}

                              tell application "Finder"

                                        set verFile to verFile as string

                              end tell

  open file verFile as PDF with options verOptions

  flatten document doc2

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 16, 2010 Jun 16, 2010

Copy link to clipboard

Copied

Please also send me the patch plug in.

tom dot thielke at qg dot com.

Thanks!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 16, 2010 Jun 16, 2010

Copy link to clipboard

Copied

The plugin would be most helpful here too.

Please send to: arrowstotle    mac dot com.

Thanks in advance.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 14, 2011 Apr 14, 2011

Copy link to clipboard

Copied

Hi, I am the original poster and it's funny that to do this day, doing a Google search on Applescript problems with CS5 brings up my post (I am honored). I'd like to tell Adobe in no uncertain terms the poor attention to Applescript cost them about 10 potential CS5 upgrades, and if CS6 continues to have broken scripts, without the ability to even tell the current document to do something, you will probably lose a customer for like (or, I'll stay at CS3 for the remainder of my company's lifespan). If I need to totalyl rework all my scripting from the ground up I'll find another tool to based my business around.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Apr 14, 2011 Apr 14, 2011

Copy link to clipboard

Copied

Peter, could you please give us an example to show the problems you encountered? Thanks a lot.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 26, 2011 Jun 26, 2011

Copy link to clipboard

Copied

I am having a somewhat similar problem. I have a script that worked perfectly in CS4, except for the limitations of CS4 with printing. I have upgraded to the trial version of CS5 because supposedly the actions in CS5 record printing preferences. The following script worked PERFECTLY in CS4. Now when I run it in CS5 I get an error "Photoshop CS5.1 has an error: file some object wasn't found."

I didn't change ANYTHING in the script except for telling it to use CS5 instead of CS4, and the name of the action (because I made a new one in CS5)

on adding folder items to this_folder after receiving these_items
    
     try
          tell application "Finder"
               repeat with i from 1 to number of items in these_items
                    try
                         set this_item to item i of these_items
                        
                         tell application "Adobe Photoshop CS5.1"
                              open this_item
                              do action "deskjet9800" from "photobooth"
                             
                         end tell
                    on error error_message
                         tell application "Finder"
                              display dialog "Error for item " & (this_item as string) ¬
                                   & ": " & error_message buttons {"Continue", "Cancel"} ¬
                                   default button 1 giving up after 120
                         end tell
                    end try
               end repeat
          end tell
     on error error_message
          tell application "Finder"
               display dialog error_message buttons {"Cancel"} ¬
                    default button 1 giving up after 120
          end tell
     end try
    
end adding folder items to

Any help would be greatly appreciated. This is REALLY frusterating!!!

Oh, and I'm on a Mac, 10.5.8, with Photoshop CS5 12.1 x64

And I do have the scripting plug in in the automate folder.

And I tried removing the "do action" line, to see if Photoshop would just open the image, and got the same error.

Michelle

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 26, 2011 Jun 26, 2011

Copy link to clipboard

Copied

Ok, I kept on digging after I posted, and I actually solved my own problem, so I thought I would share it with you.

on adding folder items to this_folder after receiving these_items
    
     try
          tell application "Finder"
               repeat with i from 1 to number of items in these_items
                    try
                         set this_item to item i of these_items
                        
                        
                         -- Coerce each alias to string
                         set this_item to this_item as string
                        
                         tell application "Adobe Photoshop CS5.1"
                             
                              open alias this_item showing dialogs never
                             
                              do action "deskjet9800" from "photobooth"
                             
                             
                         end tell
                    on error error_message
                         tell application "Finder"
                              display dialog "Error for item " & (this_item as string) ¬
                                   & ": " & error_message buttons {"Continue", "Cancel"} ¬
                                   default button 1 giving up after 120
                         end tell
                    end try
               end repeat
          end tell
     on error error_message
          tell application "Finder"
               display dialog error_message buttons {"Cancel"} ¬
                    default button 1 giving up after 120
          end tell
     end try
    
end adding folder items to

I also changed the CS5 preferences to open in 32 bit mode, because somewhere, someone said to do that. And now it's working, so I'm just going to leave it that way!

In case anyone is wondering, this is a home made photobooth that I'm making for my wedding. The action that PS5 is calling opens the file, scales it to 5 inches wide, then crops it to 7 inches tall, then saves and prints the image. It then opens another file, copy and pastes a "frame" onto the image (that says thanks for coming, and has the wedding date), then saves it to a different folder, and prints a second copy for them to take home with them. Then closes all of the images and waits for the next one.

Not all that complicated really, and saved me $1000 in photobooth rental fees. Sure, it's costing me paper and ink, and the supplies to build the booth itself ($50 in PVC pipe and connectors, I'm borrowing the fabric), but I'm out about $100 at this point, I learned a lot about scripting and I have the satisfaction of doing it myself!!! lol

THANKS!

Michelle

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines