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 tellThe 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 1333How can I switch to the other document please?