Five ways to implement Linux batch rename files
Linux batch renaming files refers to the unification of certain files to rename, to change the name of the original batch of files, described here Five ways to achieve.
AD:
Linux batch renaming files involves changing a letter, changing some connected letters, changing the letters in certain positions, adding some letters to the front, or changing the case of the letters. Completing the five methods here will basically solve the work of Linux batch renaming.
1. I want to change the first 1 letters of their names to "Q", the other unchanged
[[email protected] mailqueue]# for i in ' ls '; Do mv-f $i ' echo $i | Sed ' s/^./q/'; Done
or write a script that looks clearer:
- For file in ' ls '
- Do
- newfile = ' echo $i | sed ' s/^./q/'
- MV $file $newfile
- Done
2, modify the front 5 letters for Zhaozh
[[email protected] mailqueue]# for i in ' ls '; Do mv-f $i ' echo $i | Sed ' s/^...../zhaozh/'; Done
3, modify the following 5 letters for snail
[[email protected] mailqueue]# for i in ' ls '; Do mv-f $i ' echo $i | Sed ' s/.....$/snail/'; Done
4. Add _hoho_ in front
[[email protected] mailqueue]# for i in ' ls '; Do mv-f $i ' echo ' _hoho_ ' $i '; Done
5. All lowercase letters become uppercase letters
[[email protected] mailqueue]# for i in ' ls '; Do mv-f $i ' echo $i | TR A-Z '; Done
Above is v to complete the Linux batch renaming method.
Five ways to implement Linux batch rename files