Using the perl
rename utility:
rename 's/\(\d\d\d\d\)//' */*.mp4
If you want a dry-run to see what it would do, use the -n
(aka --nono
) option:
rename -n 's/\(\d\d\d\d\)//' */*.mp4
On Debian (and Ubuntu, etc), the perl-based rename is in the file-rename
package. It may also be invoked as prename
or file-rename
.
BTW, one very useful feature of this version of rename is that while it's trivially easy to do sed
or tr
style transformations on filenames, you can actually use ANY perl code that modifies $_
to rename files, up to an including complex scripts.
From the man page:
rename
renames the filenames supplied according to the rule
specified as the first argument. The perlexpr
argument is a Perl
expression which is expected to modify the $_
string in Perl for at
least some of the filenames specified. If a given filename is not
modified by the expression, it will not be renamed. If no filenames
are given on the command line, filenames will be read via standard
input.
For example, to rename all files matching "*.bak" to strip the extension, you might say
rename 's/\.bak$//' *.bak
To translate uppercase names to lower, you'd use
rename 'y/A-Z/a-z/' *
Note that there are other versions of rename
with completely different command-line options and arguments, including one in the util-linux
package (often named /usr/bin/rename.ul
). It's important to verify which version of rename
you have installed before using it - or, more accurately, which one is called or sym-linked to /usr/bin/rename
On Debian and Ubuntu and related systems, you can check with update-alternatives
:
# update-alternatives --display rename
rename - auto mode
link best version is /usr/bin/file-rename
link currently points to /usr/bin/file-rename
link rename is /usr/bin/rename
slave rename.1.gz is /usr/share/man/man1/rename.1.gz
/usr/bin/file-rename - priority 70
slave rename.1.gz: /usr/share/man/man1/file-rename.1p.gz