Photoshop, copy layer from one open document

So I am trying to copy one layer to another with applescript but I can't select the document I want to copy it to.


tell application id "com.adobe.photoshop"
  activate
  set starter_image to name of current document
  log starter_image
  set AppleScript's text item delimiters to {".jpg"}
  set Destination_Image to (first text item of starter_image) & "_2.jpg"
  log Destination_Image
  tell current document
  set Main_Image to layer "Main Image"
  select all
  copy selection
  end tell
  set current document to Destination_Image
end tell


The result is this

tell application "Adobe Photoshop CC 2018"
  activate
  get name of current document
  --> "MM--MKY000050WH.JPG"
  (*MM--MKY000050WH.JPG*)
  (*MM--MKY000050WH_2.jpg*)
  get layer "Main Image" of current document
  --> art layer 1 of document "MM--MKY000050WH.JPG"
  select all current document
  --> current application
  copy selection of current document
  --> current application
  set current document to "MM--MKY000050WH_2.jpg"
  --> error "Object expected" number 1333
Result:
error "Adobe Photoshop CC 2018 got an error: Object expected" number 1333


How can I switch to the other document please?

Posted on Apr 9, 2018 2:07 AM

Reply

Similar questions

2 replies

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Photoshop, copy layer from one open document

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.