Here is a break-down of what your function is currently doing:
(defun renamefile ( )
(foreach x (vl-directory-files "c:/pdfplot" "*.pdf")
;; Assuming the directory 'c:/pdfplot' exists
;; and contains one or more files with the .pdf
;; extension, since vl-directory-files has been
;; called without the 'directories' integer argument
;; the foreach symbol 'x' could be a PDF filename,
;; the name of a subfolder within the directory 'c:/pdfplot'
;; or the current folder & parent folder placeholders "." & ".."
(foreach y (layoutlist)
;; The foreach symbol 'y' will now be assigned the name
;; of each paperspace drawing layout in the active drawing
(vl-file-rename x (strcat y ".pdf"))
;; Below is what the above expression may look like within
;; this foreach loop:
;;
;; (vl-file-rename "myfile.pdf" "Layout1.pdf")
;; (vl-file-rename "myfile.pdf" "Layout2.pdf")
;; ...
;; (vl-file-rename "myfile.pdf" "Layout3.pdf")
;;
;; Note that 'x' only holds the filename of the PDF file,
;; not the full filepath, hence AutoCAD will search the
;; working directory for a file with filename equal to
;; that held by 'x'.
;;
;; If such a file can be found, this file is renamed to
;; the first layout in the list returned by (layoutlist)
;;
;; If this renaming operation is successful, the next
;; evaluation of the vl-file-rename function will fail
;; since the filename held by the symbol 'x' no longer
;; exists.
;;
;; If the rename operation has failed because the file
;; held by the symbol 'x' cannot be found, then all
;; subsequent calls to the vl-file-rename function will
;; also fail within the nested foreach loop, when the
;; function attempts to rename the file to every layout
;; name in the active drawing.
)
)
)