1 Reply Latest reply: Nov 20, 2013 8:02 AM by Michael L Hale RSS

    File won't save in CS5 but does in CC need to make it back compatible

    Mattmcquiff Community Member

      This is my script, it runs fine in Photoshop CC but not on CS5.1 It does most of the script but will not save it comes up with the error

       

        save current document in file "Images3:2013-2014:WK99:Top:Top_WK99_PSD:TM15WA00124SV1RH.png" of current document as PNG with options {class:PNG save options, compression:1, interlaced:false} without copying

        --> error number -1728

      Result:

      error "Adobe Photoshop CS5.1 got an error: Can’t get current document." number -1728 from current document

       

       

       

       

       

      set theFolder to POSIX path of (choose folder with prompt "Select Folder")

      set theFolder2 to text 1 thru -2 of theFolder

      log theFolder2

       

      set dtF to paragraphs of (do shell script "find  " & quoted form of theFolder2 & " -iname \"*.PSD\"")

       

      set tc to (count dtF)

      repeat with i from 1 to tc

                set thefile to item i of dtF

       

                tell application id "com.adobe.Photoshop"

        activate

        open (alias thefile) showing dialogs never

                          set display dialogs to never

                          set thePath to do shell script "dirname " & quoted form of thefile

       

                          set SaveLocation to (POSIX file thePath) as string

       

                          set origName to name of current document

                          set myPNGOptions to {class:PNG save options, compression:1, interlaced:false}

                          tell current document

       

       

        --If the quick mask mode has been left on then delete the channel Quick Mask

                                    try

        --for CS5

                                              if (quick mask mode) then delete channel ¬

                                                        "Quick Mask"

                                    on error

        --for CS6 and up

                                              if (quick mask mode) then delete channel ¬

                                                        "Alpha"

                                    end try

        --If the Layer is incorrectly labeled with Original Layer it needs renaming to original Image

                                    if (exists layer "Original Layer") then ¬

                                              tell layer "Original Layer" to set name to "Original Image"

       

       

                                    (delete layer "Original Image")

        --set hS to current history state

                                    delete layer "BACKGROUND" of layer set "Dodge and Burn"

                                    move layer "Main Image" of layer set "Dodge and Burn" to after layer set "Dodge and Burn"

                                    delete layer set "Dodge and Burn"

        delete layer set "Retouch"

        trim basing trim on transparent pixels

        save in (SaveLocation & origName) as PNG with options myPNGOptions without copying

                                    close without saving

                          end tell

       

                end tell

       

                set FileLocation to (POSIX file thefile) as string

                tell application "Finder" to delete FileLocation

       

       

      end repeat