Five ways to implement Linux batch rename files

Source: Internet
Author: User

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:

    1. For file in ' ls '
    2. Do
    3. newfile = ' echo $i | sed ' s/^./q/'
    4. MV $file $newfile
    5. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.