I have a directory (Linux user) with a number of files which contain an added [!] to the end of each file name so that each file reads out as:
- foo something [!].zip
- bar something [!].zip
- helloworld [!].zip
- etc.
What is the quickest way to batch rename these to remove the ending [!] character combination from these file names?
Best Answer
You can use the
rename
tool like thisI recommend that you first add the
-n
switch, which causesrename
to just show what it will do, but not rename any files.Note that this will only remove the first occurence of
[!]
in the filename, only if it is preceded by a space, and regardless of whether it is at the end of the filename or not.basic syntax of
rename
:will replace
from
withto
in all filenames.here is a detailed explanation: https://www.computerhope.com/unix/rename.htm
note there are two
rename
commands: one from the util-linux package and one from the perl package. the command i refer to above is the perl variant. the perl variant is much more popular and useful. usually when people talk aboutrename
they mean the perl variant.in debian (and therefore ubuntu)
rename
is the perl variant by default. https://stackoverflow.com/questions/22577767/get-the-perl-rename-utility-instead-of-the-built-in-renamein arch linux
rename
is the util-linux variant whileperl-rename
is the perl variant. https://bbs.archlinux.org/viewtopic.php?id=85128here is how you can see what version you are using: