4 Replies Latest reply on Apr 1, 2016 5:03 AM by BC Printing

    AppleScript 'current document' seems to be broken in Photoshop CC


      I'm using AppleScript to control Photoshop's web export, on a Mac running OS X 10.8.4. Essentially, I want to open a document and resave it using the Web Export options.


      The following script snippet worked fine in Photoshop CS5:


      on process_item(this_item)

                set thePath to this_item as string

                tell application "Adobe Photoshop CS5"

        open alias thePath

                          set theDocument to current document

        export theDocument in thePath as save for web with options {web format:JPEG, quality:60}

        close theDocument saving no

                end tell

      end process_item


      However, if I change the application name to "Adobe Photoshop CC", then the script stops working. As soon as it reaches the request for 'current document', Applescript throws an error:


         "Can't get document 'somedocument.jpg' of application "Adobe Photoshop CC".


      where 'somedocument.jpg' is the name of my document. Note that AppleScript (or Photoshop) is aware of the document at some level - it shows the correct name. It just can't "get" it, and the whole process grinds to a halt.


      If I open the document manually, then run an Applescript that just does the


        set theDocument to current document


      command, Photoshop gets the document object without difficulty.


      I've tried inserting a delay after opening the file, or using different ways to refer to the current document. I've verified that Photoshop is actually aware of open documents by using 'count' to find out how many documents are open. However, nothing I can think of will make this previously functional script work with Photoshop CC.


      Has anyone encountered this problem or found a workaround? Thanks.