I working on a JFS filsystem made with the option -O (case insensitive filenames).
How can I easily rename a file from Test.txt to test.txt ?
Using mv report the error:
mv: ‘Test.txt’ and ‘test.txt’ are the same file
And nautilus reports
The name “test.txt” is already used in this location. Please use a different name.
Now I can rename it to Test2.txt followed by renaming to test.txt
You can use the
rename
command.It's not actually a built-in shell command, like
mv
, but a pearl script that comes by default with most GNU/Linux distros. It's usage is a bit different frommv
because it uses Pearl regular expressions to compare against a list of files.Here's how to use it in your case:
rename 's/Test\.txt/test\.txt/' *
The
s
tells therename
command to search and replace all occurrences of Test.txt with test.txt. The dots.
inside the regular expression must be escaped with a\
, that's why the filenames are written likeTest\.txt
. Notice the*
at the end of the command, that means to look through all files in the current directory.You can pass the
-n
option to therename
command if you want to test it without making any changes.