If a directory contains so many files with the extension .txt and if you want to rename it to some other extensions follow the step
# cd /directory/contains/file
shows result before renaming
# rename -n 's/\.txt$/\.bak/' *.txt (file we want to change)
# rename 's/\.txt$/\.html/' *.txt
# rename 's/.txt/.md/i' *
# rename 's/.txt/.md/i' *
It is useful if the directory contains a lot of files to edit in a single step.
-n, --no-act
No Action: show what files would have been renamed
* Also we can convert upper case letters to lowercase and vice versa
# rename 'y/A-Z/a-z/' *
No Action: show what files would have been renamed
* Also we can convert upper case letters to lowercase and vice versa
# cd /directory/contains/file
* Renaming file name from:
ctechz.txt0
ctechz.txt1
ctechz.txt2
ctechz.txt3
ctechz.txt4
ctechz.txt5
ctechz.txt1
ctechz.txt2
ctechz.txt3
ctechz.txt4
ctechz.txt5
To file name:
ctechzblog.txt
ctechzblog.txt0
ctechzblog.txt1
ctechzblog.txt2
# rename 's/ctechz/ctechzblog/g' ctechz.txt*
No comments:
Post a Comment