Using the perl
rename command (which is completely different to the rename
command from util-linux
):
rename -v 's/^(\d{4})(\d{2})(\d{2})/$1-$2-$3/' 2015*
(use -n
rather than -v
for a dry-run to test the command first).
This perl version of rename
may be called prename
or file-rename
on your system. It is far more capable and useful than the util-linux
version of rename
. If you don't have it installed, you should install it. If it isn't packaged for your distro, you can install from CPAN
BTW, you can tell if you already have it installed by running rename -V
. If it produces output like this:
$ rename -V
Unknown option: V
Usage: rename [-v] [-n] [-f] perlexpr [filenames]
or this:
$ rename -V
/usr/bin/rename using File::Rename version 0.20
Then you have perl rename
installed. The former indicates an old version (which AFAIK lives on only on pre-jessie debian installs, included as part of the perl
package). The latter indicates the current version (now a separate package called rename
).