The last one I put together for someone on here was all copied from the internet - nothing wrong with that!
Might try something like:
(defun c:testthis ( / MySS ) ; define the function, thest this, define local variables after the '/'
(setq MySS (ssget "_A") ) ; Make a selection set - a selection of everything (ssget) with a filter "_A" - excluding locked layers
(command "copybase" (list 0 0) MySS "") ; Run the CAD command "Copybase". Whjat is after it is all the imputs you'd normally do
)
as a simple start to copy everything on the drawing apart from locked layers. Added some notes - it isn't too hard to follow these 4 lines though
From there just search out each step as you need - perhaps the next one is "how to delete a selection set" and just add it in, using MySS