There are 2 versions of the rename command, a perl version for debian-based distros and the util-linux version which all other distros use. source
The page is written for the perl version.
This can cause problems (which it did for me because I'm using fedora) for users with the util-linux version because it doesn't use Perl expressions.
Perl: man-page
util-linux: man-page
I can't think of a solution for this problem... :/
Thank you for bringing this up, @principis.
I spent some time and did some research, and here's a summary of what I could find about the rename command. I'd like to emphasize that this is based on my two main systems, which are Debian and Ubuntu.
These are the three programs which are contenders for this page:
prename: this is a Perl script provided by the perl package (along with Perl itself). This script is no longer provided by the perl package on Ubuntu 17.10 and newer, but is still provided by the perl package for the latest LTS of Debian (Debian 9). I did not check whether or not it is still provided by perl on later Debian versions.
SYNOPSIS from `man prename`:
rename [ -v ] [ -n ] [ -f ] perlexpr [ files ]
file-rename: this is still a Perl script and is provided by the rename package. This is basically an updated version of prename. This can be installed either in Debian or Ubuntu and it is the same command on both distros.
SYNOPSIS from `man file-rename`:
rename [ -h|-m|-V ] [ -v ] [ -n ] [ -f ] [ -e|-E perlexpr]*|perlexpr [ files ]
rename.ul: this is a compiled C program provided by the util-linux package. This package has a Priority of Required, and therefore comes built-in in both Debian and Ubuntu.
SYNOPSIS from `man rename.ul`:
rename [options] expression replacement file...
So what's the deal? Which one is used and where?
The prename command is installed as an alternative[1] on Debian and Ubuntu <= 17.04. So basically this command is only still present in Debian.
The file-rename command is installed as an alternative on both Debian and Ubuntu.
The rename.ul[2] command is not installed as an alternative, and is therefore a standalone executable on both Debian and Ubuntu.
My suggestion
The TL;DR from what I explained above is that prename and file-rename are two alternatives for the rename command and are both Perl scripts, with file-rename being the more updated, and prename being seemingly deprecated on newer distros. The rename.ul command is a standalone command which does not seem to conflict with the other two.
Given these facts, I would suggest to:
rename.md page under Linux.rename.md as is, and create a new rename.ul.md page.rename.md (and reaname.ul.md if created) specifying which command is exactly being described.[1] Being installed as an alternative, for those who don't know, means that /usr/bin/rename is a symlink to /etc/alternatives/rename, and this second one is a symlink to whichever rename command is configured as default alternative (through the update-alternatives command).
[2] Note that rename.ul is the actual name of the command. That is, no rename command exists on Ubuntu 18 if you only have installed util-linux and not rename. I don't know if the .ul prefix was added or has been there since the beginning, but at least on my two machines using Ubuntu 18.04 (one AWS Micro instance and one personal laptop) it's like this.
As additional data, here's the information from Homebrew on macOS:
$ brew info rename
rename: stable 1.600 (bottled), HEAD
Perl-powered file rename script with many helpful built-ins
http://plasmasturm.org/code/rename
Conflicts with:
util-linux (because both install `rename` binaries)
Not installed
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/rename.rb
Is this consistent with your findings, @mebeim?
Update on other distributions and systems after some more digging:
CentOS 7, RHEL 8: the rename command is the C executable from util-linux, no prename or file-rename. No rename package is available through the yum package manager, and yum list all | grep rename yields nothing.
Fedora 30: the rename command is the C executable from util-linux, prename is available in the prename package.
openSUSE 15.1: the rename command is the C executable from util-linux. No rename package is available through the zypper package manager, zypper search rename lists H2rename, but that's an entirely different program.
MacOS (using Homebrew): rename is provided both by the util-linux and rename Homebrew packages. This means the two packages conflict. The rename pkg provides a Perl script, and the util-linux pkg provides a C compiled program. The Perl script however seems to differ from the Debian/Ubuntu file-rename and prename: it has more and maybe even different command line options (didn't check them by hand). A page should probably be created under the macos platform to avoid any problem. This should answer your question @waldyrious.
Windows 10: the rename command exists, but is entirely different in both purpose and syntax.
Solaris 11: as far as I could see, there's no rename command in Solaris. I cannot see one in the online documentation. I did not test this though, my Solaris VM isn't currently working.
So basically the main problem here is that on Linux, we have some distros which have a rename command which currently fits the existing rename.md page (Debian, Ubuntu), but also others which only have the different rename command from util-linux (CentOS, Fedora, RHEL, openSUSE).
I would still suggest what I said above. Moving rename.md under linux and adding a line to the description seems like the way to go to me.
Sounds good to me. Thanks for the research :)
I'll create a PR. Is this line fine? Or maybe too long?
> Keep in mind that this page concerns the perl version of rename, often known as `prename` or `file-rename`. See `rename.ul` for the util-linux version.
Wow, that's wildly complicated.
@principis: Sounds a bit on the wordy side. What about something like this?
> This is the perl version of `rename`, which is the default on Debian. See `rename.ul` for the stand-alone version.
@mebeim just to make sure we all understand the status quo, would you mind compiling the information above into a table? Something like this (just a draft; incomplete and almost surely incorrect):
| | Perl
(vX) | Perl
(vY) | Perl
(vZ) | C | Other |
|------------------|---------------|---------------|---------------|---|-------|
| Linux (Debian) | rename → prename | file‑rename | | rename.ul | |
| Linux (Ubuntu) | rename → prename | file‑rename | | rename.ul | |
| Linux (CentOS, Fedora 30, RHEL 8) | | | | rename | |
| Linux (OpenSuse) | | | |
| macOS (Homebrew) | | | rename | rename | |
| Windows | | | | | rename |
Sure @waldyrious, that's actually a pretty good idea. I also took a look at Arch Linux. Here's a table:
| | Perl (old) | Perl (new) | Perl (other?) | C |
|-|-|-|-|-|
| Linux (Debian) | prename (pkg perl), deprecated | file‑rename (pkg rename) | N/A | rename.ul (pkg util-linux) |
| Linux (Ubuntu) | N/A | file‑rename (pkg rename) | N/A | rename.ul (pkg util-linux) |
| Linux (Arch) | N/A | N/A | perl‑rename (pkg perl-rename) | rename (pkg util-linux) |
| Linux (CentOS, RHEL) | N/A | N/A | N/A | rename (pkg util-linux) |
| Linux (Fedora) | N/A | N/A | prename (pkg prename) | rename (pkg util-linux) |
| Linux (openSUSE) | N/A | N/A | N/A | rename (pkg util-linux) |
| macOS (Homebrew) | N/A | N/A | rename (pkg rename) | rename (pkg util-linux) |
| Windows | N/A | N/A |N/A | N/A |
| Solaris | N/A | N/A | N/A | N/A |
Oh boy, that's really a mess... :disappointed_relieved: I really don't get why Debian (or at least Ubuntu) didn't go with the util-linux command by default (or why they don't even offer it as an alternative).
Important notes:
rename is a different command (therefore I did not list it above).rename command exists.rename and util-linux conflict.rename offers a Perl script that looks different from others.perl-rename offers a Perl script that also looks different from others.prename offers a Perl script that also looks different from others.prename and file-rename are alternatives for rename.file-rename is the only alternative for rename.@mebeim Debian was first with the perl command in 1999.... According to this post
On fedora prename is also available but not installed by default. It's this version.
Jesus, what a mess indeed. Thanks so much for doing the table!
So after this, I suppose the next step is to create pages for the Windows and the macOS rename commands, just for completeness? Nice-to-haves would be the perl-rename, which is unique to Arch Linux, and prename assuming it's the same version in Debian and Fedora.
Also, what's up with the Arch and macOS/brew versions being different programs altogether? Is the original Perl rename not developed anymore? Would it make sense to suggest to both repositories to switch to the "standard" Perl rename implementation, to reduce user confusion?
@principis oh you're right there's the prename package... I don't know how I missed that. I updated my posts above. This is really wild.
So @waldyrious yes, first of all I would remove rename.md from common, and move it to linux. Then create two different pages for macOS and Windows. That's a start.
On Debian, prename says:
Deprecated program in use: rename as shipped with the Debian perl package will be removed after the release of stretch. Please install the separate 'rename' package which will provide the same command.
so that's out of the game I'd say.
As for the differences in all the Perl scripts, they really seem to be different, or at least they have different command line options. It's reeeeally confusing. I took a look at the authors for the ones I listed above, and they indeed are all different except macOS and Fedora (funny, huh).
prename from pkg perl: Robin Barker & Larry Wall.file-rename from pkg file-rename: Larry Wall.perl-rename from pkg perl-rename: Peder Stray (same as Fedora). prename from pkg prename: Peder Stray (same as Arch).rename from pkg rename: Aristotle Pagaltzis.The thing is that apparently a lot of people like to re-write their own version of rename inspired by the original Larry Wall's Perl example script.
I would suggest the following:
Have linux/rename.md with examples for the program in the util-linux pkg, which is the most commonly available and consistent tool, with the following warning in the description:
> NOTE: this page refers to the command from the `util-linux` package.
> For the Perl version, see `file-rename` or `perl-rename`.
Have linux/file-rename.md with examples for Debian and Ubuntu file-rename.
Have linux/perl-rename.md with examples for Arch's perl-rename, maybe with the following warning in the description:
> NOTE: this page refers to the command provided by the `perl-rename` Arch Linux package.
Have macos/rename.md with examples for the program in the util-linux pkg (same reasoning as above), maybe with the following warning in the description:
> NOTE: this page refers to the command from the `util-linux` Homebrew package.
Have windows/rename.md, with other examples since it's a different command.
@mebeim the Peder Stray versions seems to be adapted from Larry Wall's script
AUTHOR
Peder Stray pederst@cpan.org, original script from Larry Wall.
What do we do with prename? symlink it to perl-rename? (it may break clients) or just leave it or copy it with a different description?
@principis yes, but the Peder Stray's one is still a very different script. As for prename that's a good question. I'm not really sure about using symlinks... @waldyrious what do you think?
If we can use symlinks, and have them work properly (e.g. if when cloning the repo on linux, macos and windows) I'd say there's no downside to it. I'm not sure clients would have issues with them if they are properly replicated in the local filesystem.
In any case, the prename command is both old and not the default anywhere, so it's not a big deal if we don't have it covered, for the time being at least.
@waldyrious the fedora prename is the same as arch's perl-rename. (I forgot there is a Debian prename). This is terrible :o
Yep, that's the point @principis was making, he was talking about Fedora's prename, not Debian's prename. Do symlinks work fine cross platform and most importantly inside a ZIP archive? That was my main concern. Cloning is not the problem.
Most helpful comment
Thank you for bringing this up, @principis.
I spent some time and did some research, and here's a summary of what I could find about the
renamecommand. I'd like to emphasize that this is based on my two main systems, which are Debian and Ubuntu.These are the three programs which are contenders for this page:
prename: this is a Perl script provided by theperlpackage (along with Perl itself). This script is no longer provided by theperlpackage on Ubuntu 17.10 and newer, but is still provided by theperlpackage for the latest LTS of Debian (Debian 9). I did not check whether or not it is still provided byperlon later Debian versions.file-rename: this is still a Perl script and is provided by therenamepackage. This is basically an updated version ofprename. This can be installed either in Debian or Ubuntu and it is the same command on both distros.rename.ul: this is a compiled C program provided by theutil-linuxpackage. This package has aPriorityofRequired, and therefore comes built-in in both Debian and Ubuntu.So what's the deal? Which one is used and where?
The
prenamecommand is installed as an alternative[1] on Debian and Ubuntu <= 17.04. So basically this command is only still present in Debian.The
file-renamecommand is installed as an alternative on both Debian and Ubuntu.The
rename.ul[2] command is not installed as an alternative, and is therefore a standalone executable on both Debian and Ubuntu.My suggestion
The TL;DR from what I explained above is that
prenameandfile-renameare two alternatives for therenamecommand and are both Perl scripts, withfile-renamebeing the more updated, andprenamebeing seemingly deprecated on newer distros. Therename.ulcommand is a standalone command which does not seem to conflict with the other two.Given these facts, I would suggest to:
rename.mdpage under Linux.rename.mdas is, and create a newrename.ul.mdpage.rename.md(andreaname.ul.mdif created) specifying which command is exactly being described.[1] Being installed as an alternative, for those who don't know, means that
/usr/bin/renameis a symlink to/etc/alternatives/rename, and this second one is a symlink to whicheverrenamecommand is configured as default alternative (through theupdate-alternativescommand).[2] Note that
rename.ulis the actual name of the command. That is, norenamecommand exists on Ubuntu 18 if you only have installedutil-linuxand notrename. I don't know if the.ulprefix was added or has been there since the beginning, but at least on my two machines using Ubuntu 18.04 (one AWS Micro instance and one personal laptop) it's like this.