1

What is the function to move files? I want to emulate the following shell command:

mv file dir

As described here, the closest is rename-file, but this would be emulating this:

mv file newfile

1 Answer 1

5

That function can actually move files to directories, but its documentation was not in accord with its features. If the destination ends in a /, then the file is moved. e.g.

(rename-file "foo" "bar/")

will move foo into the directory bar.

3
  • is a slash portable? How to build a dirname from a string in a portable way?
    – blueFast
    Jul 24, 2018 at 7:53
  • 2
    (file-name-as-directory "bar") is the portable way to do that.
    – rpluim
    Jul 24, 2018 at 9:41
  • OP: Please consider accepting this answer. I believe it's what you're looking for.
    – Drew
    Nov 10, 2018 at 18:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.