What's the best way to move a file in Lisp in an implementation-independent way? For example I have an image file:
(setq oldpath #P"SERVER:PICTURES;TEMP;PHOTO.PNG")
and I want to move it out of the TEMP directory into the PICTURES directory. This seems to work:
(setq newpath
(make-pathname
:host (pathname-host oldpath)
:directory (butlast (pathname-directory oldpath))
:name (pathname-name oldpath)
:type (pathname-type oldpath)))
(rename-file oldpath newpath)
but is there a more elegant way?
Thanks, David
I'm usually using:
(make-pathname :defaults old-path
:directory (butlast (pathname-directory oldpath)))
The :defaults
argument makes sure that all relevant parts of the old pathname are being copied over.