In essence a script file is just a list of commands saved into a file saved with a scr suffix (*.scr)
You might have something like this then saved as "scriptfile.scr"
PASTECLIP
0,0
to run this as a script you might then use this command - this should paste from the clipboard to point 0,0 using the above example (I am writing this from the top of my head, no checking)
(command "_.SCRIPT" "c:\\User\\scriptfile.scr")
To make use of a script file then you also want to add in something to open a file like
_.OPEN "C:\Users\MyFirstDrawing.dwg"
and to close a drawing:
(vla-close (vla-item (vla-get-documents (vlax-get-acad-object)) "MyFirstDrawing.dwg") :vlax-false)
this line just closes the drawing no saving so add that in as well. A quirk I found is that to make it work - for me - I had to open the next file before closing the previous one. Putting it all together you might have a script file like this:
_.OPEN "C:\Users\Drawing 1".dwg"
PASTECLIP
0,0
qsave
_.OPEN "C:\Users\Drawing 2.dwg"
(vla-close (vla-item (vla-get-documents (vlax-get-acad-object)) "Drawing 1.dwg") :vlax-false)
PASTECLIP
0,0
qsave
_.OPEN "C:\Users\Drawing 3.dwg"
(vla-close (vla-item (vla-get-documents (vlax-get-acad-object)) "Drawing 2.dwg") :vlax-false)
PASTECLIP
0,0
qsave
_.OPEN "C:\Users\Drawing 4.dwg"
(vla-close (vla-item (vla-get-documents (vlax-get-acad-object)) "Drawing 3.dwg") :vlax-false)
PASTECLIP
0,0
qsave
(vla-close (vla-item (vla-get-documents (vlax-get-acad-object)) "Drawing 3.dwg") :vlax-false)
Something like this should run through a range of closed drawings, open them in turn and paste something at 0,0 when you use the (command ....) line from above. It is easier to use a dialogue box to build up the list of files to work on.
As for a script to run on only opened files, I have found this to be very limited - happy to be corrected and shown a better way - and the examples out there only show for example switching tabs or similar - certainly not a full range of commands like this example would let you do. The core console is very fast but also limited with some LISP commands like it doesn't like VLA- commands
If you can I would consider closing all the files and running the script on them like that - the examples are out there to use
Of course, happy to see if someone can answer you with a better solution.