Seeing José’s new issue Add File.rename!, made me look into the module, and realize that we don’t have a “move” function, and
File.rename/2 is the only one we have.
This has been inherited from Erlang, and actually, it is delegated to :file.rename/2.
This module also provides higher level functions that work with filenames and have their naming based on UNIX variants.
Historically (since the very first version of AT&T UNIX)
mv had been the solution for renaming and moving files and directories.
rename shell command works with Perl regular expressions. First argument is a regular expression, in the shape of ‘s/foo/bar’ or ‘y/A-Z/a-z/’, and the second argument is a list of files. So it is completely different than
On the other hand,
File.rename/2 mimics the way the
mv shell command works, where first argument is the SOURCE and second argument is the DESTINATION.
Their uses are different,
rename command is used to rename from one to a large quantities of files in one go. While
File.rename/2 can only rename one file at a time.
So before adding a new
File.rename!/2 function, and for the sake of consistency, I propose to consider having
- Add File.rename! - GitHub Issue: https://github.com/elixir-lang/elixir/issues/8604
- Elixir’s File.rename/2 documentation: http://hexdocs.pm/elixir/File.html#rename/2
- Erlang’s file.rename/2 documentation: http://erlang.org/doc/man/file.html#rename-2
- Linux’s mv manpage: https://linux.die.net/man/1/mv
- Linux’s rename manpage: https://linux.die.net/man/1/rename
- Wikipedia’s List of Unix Commands: https://en.wikipedia.org/wiki/List_of_Unix_commands