Bash rename files

This is an example how to rename files with regex.

At first we need to create some files:

`touch {1,2}OLD.txt`;
`touch {1,2}TEST.txt`;

Lets look what we got:

sh-4.2# ls
1OLD.txt  1TEST.txt  2OLD.txt  2TEST.txt

now rename this files:

rename 's/OLD/NEW/' *.txt

And we see the renamed files:

sh-4.2# ls
1NEW.txt 1TEST.txt 2NEW.txt 2TEST.txt

Leave a Reply

Your email address will not be published.

3 × 1 =