tested just enough to make sure it works:
(defun c:DO (/ #Choice #Entsel #Entget #Layer #ssget) (setvar "cmdecho" 0) (setvar "errno" 0) (initget 0 "Back Front") (setq #Choice (getkword "\nDraworder Option [back/Front] : ")) (progn (if (not #Choice) (setq #Choice "Back") ) ;_ if (while (and (not (eq (getvar "errno") 52 ) ;_ eq ) ;_ not (not #Entsel) ) ;_ and (setq #Entsel (entsel (strcat "\nSelect object on layer to move to " #Choice ": " ) ;_ strcat ) ;_ entsel ) ;_ setq (if #Entsel (progn (setq #Layer (cdr (assoc 8 (entget (car #Entsel))))) (setq #ssget (ssget "_x" (list (cons 410 (getvar "ctab")) (cons 8 #Layer) ) ;_ list ) ;_ ssget ) ;_ setq (vl-cmdf "_.draworder" #ssget "" #Choice) (prompt (strcat "\nAll " (rtos (sslength #ssget) 2 0) " object(s) on layer "" #Layer "" have been moved to " #Choice ) ;_ strcat ) ;_ prompt ) ;_ progn ) ;_ if ) ;_ while ) ;_ progn (princ))