[USER=112267]@chick[/USER]
I have made some modifications to the original script which may help you, there is no need to hard code in the source/destination doc paths:
[CODE=javascript]/*
https://www.photoshopgurus.com/forum/threads/script-error-in-ps-2021.72619/
Script error in PS 2021
Copy top path from Doc A to Doc B.jsx
Modified by Stephen Marsh 2021
*/
#target photoshop
if (app.documents.length === 0) {
// open the files via native open dialog
var openSource = File.openDialog("Please select the source file:");
open(openSource);
var openDestination = File.openDialog("Please select the destination file:");
open(openDestination);
// doc variables
var sourceDoc = documents[0];
var destinationDoc = documents[1];
// set the active doc
app.activeDocument = sourceDoc;
// get the top most path from source file
sourceDoc.pathItems[0].select();
// copy the selected path
var id122 = charIDToTypeID("copy");
executeAction(id122, undefined, DialogModes.ERROR);
// set the active doc
app.activeDocument = destinationDoc;
// paste the copied path to destination file
var id126 = charIDToTypeID("past");
executeAction(id126, undefined, DialogModes.NO);
// close without any changes
sourceDoc.close(SaveOptions.DONOTSAVECHANGES);
// save with changes
destinationDoc.close(SaveOptions.SAVECHANGES);
// end of script notification
alert("Done");
}
else {
alert('No documents should be open when running this script!');
}[/CODE]
[URL unfurl="true"]https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html[/URL]