Five methods to batch rename files in Linux

Source: Internet
Author: User

In Linux, renaming files in batches involves changing a letter, changing some connected letters, changing letters at some locations, adding certain letters at the beginning, or changing the case sensitivity of letters. After completing the five methods, the Linux batch rename is basically solved.

1. I want to change the first letter of their names to "q", and the others will not change.

[Root @ pps mailqueue] # for I in 'LS'; do mv-f $ I 'echo $ I | sed's/^./q/''; done

Or write a script to make it clearer:

 
 
  1. for file in `ls`  
  2. do  
  3.   newfile =`echo $i | sed 's/^./q/'`  
  4.  mv $file $newfile  
  5. done 



2. Change the first five letters to zhaozh.

[Root @ pps mailqueue] # for I in 'LS'; do mv-f $ I 'echo $ I | sed's/^ ..... /zhaozh/''; done

3. Change the last five letters to "snail Il ".

[Root @ pps mailqueue] # for I in 'LS'; do mv-f $ I 'echo $ I | sed's /..... $/snail il/''; done

4. Add _ hoho _

[Root @ pps mailqueue] # for I in 'LS'; do mv-f $ I 'echo "_ hoho _" $ I '; done

5. Change all lowercase letters to uppercase letters.

[Root @ pps mailqueue] # for I in 'LS'; do mv-f $ I 'echo $ I | tr a-z A-Z '; done

In the preceding section, the Linux batch rename method is completed in step 5.

  1. Detailed command 1 for running Linux background)
  2. Brief Introduction to Linux kernel Security Intrusion Detection System
  3. Detailed analysis of Linux Firewall Configuration
  4. Differences between Linux and Unix
  5. About the Linux upload and download commands and how to set the path

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.