Well, some very strange things are happening.
(1) I did remove the first lines, entered the Windows file name paths, and then copied the file into the Scripts folder. After your last answer, I went back and checked, sure enough, and the .jsx file in the Scripts folder was your original without the line removed. Thinking I had made a mistake, I repeated, double-checked, deleted the Scripts file, copied the new one, certain I had changed it, and then checked the .jsx file in the Scripts folder where I had just copied it. It was the old file with that first line still in it. The file I copied was correct, the file I pasted into Scripts was not. I'm not crazy, I can reproduce this at will.
(2) Also, I had put this ONLY into the PS 2020 folder, not into the 2019 or 2021 that I also still have installed. When I checked those, the incorrect .jsx file (still with the first line) was in all three places! Not sure at what point that happened.
(3) I deleted everything and started over again, and the script (with the first line removed) when copy/pasted into the 2020 Scripts folder still had the first line in it. I checked and repeated this several times to be sure this was actually happening.
(4) I deleted everything and started over again, this time using a different text editor, and the script (with the first line removed) when copy/pasted into the 2020 Scripts folder seemed ok. So I thought maybe the first text editor was doing this, how I cannot imagine.
(5) The next attempt to run the script gave me an error on the file path name. I fiddled for a long time before I realized that although I had specified "D:\Foldername\Filename.psd", it was being changed in the .jsx file to "D:/Foldername/Filename.psd". The backslashes were being changed to forward slashes when it was copy/pasted into Scripts. I checked the files, repeated the copy/paste enough times to finally convince myself I wasn't dreaming. I can reproduce and demonstrate this. I have no idea how or why this is happening.
(6) So I finally gave up on the second text editor and tried still a third text editor! Starting over, I edited the .jsx file directly in the Scripts folder, and this managed to get the .jsx file appearing to be correct in the Scripts folder, with the backslashes.
(7) When I ran it, I still got an error saying the path was wrong. I don't know any of these scripting languages (my programming is from pre-java days), but I did manage to find an example in the Adobe documentation you referred me to, showing a path name like "D:\\Foldername\Filename.psd" (with an extra backslash), but that also didn't work. Same error, no file found.
(8) I tried again using an alternate windows path format like "/d/Foldername/Filename.psd" which also appeared somewhere in an example. This found the .psd files!!
(9) But, with that path format, although PS 2020 ran the script, it failed and gave an error saying the "command Paste is not currently available".
(10) I did this all over again, putting everything in PS 2021 and it ran to completion!! Except it didn't copy the Photoshop path from one .psd file to the other. All it copied was the top layer, not the top path. So my destination file ended up with a new layer from the source file, but NOT a new path in it.
I just wanted you to know I'm not blaming your script, which I really wish I could make work. Apparently my PhD in Computer Science (yes, really) isn't enough to cope with this.