I honestly can't remember where I got this but it works for me...
(defun c:BatchXref ()
(setvar "tilemode" 1)
(princ "\n\nPick any drawing in the set.")
(setq pickfile (getfiled "Pick any drawing in the set" "g:/" "dwg" 2)) ;;; type in your preferred path...
;
;extract just the path
(setq filelen (strlen pickfile))
(setq letter "")
(while (/= letter "\\")
(setq letter (substr pickfile filelen 1))
(setq filelen (- filelen 1))
)
(setq filelen (+ filelen 1))
(setq path (substr pickfile 1 filelen))
;
;list all floor plan drawings in that directory
(vl-load-com)
(setq filelist (vl-directory-files path "Arch*.dwg" 1)) ;;; type in the naming of your files etc...
;
;xref all floor plans into current drawing
(setq counter 0)
(setvar "filedia" 0)
(repeat (length filelist)
(setq currentfile (strcat path (nth counter filelist)))
(command "-xref" "a" currentfile "0,0,0" "1" "" "0")
(setq counter (+ counter 1))
)
(setvar "filedia" 1)
)