Linux Batch file renaming

Source: Internet
Author: User

CentOS 6.6 MV Rename are not meeting the requirements

All file name formats are as follows:

[[email protected]] [1442146016999] [<[email Protected]>] [[email protected]] [You have successfully booked "Huashan Yuhua Hotel"].html


You need to change "[" to "# # #" and delete the "[" and "]"

1. First Escape ls | Sed ' s/@/\\@/g ' | Sed ' s/\[/\\[/g ' | sed ' s/</\\</g ' | sed ' s/>/\\>/g ' | sed ' s/\]/\\]/g ' | Sed ' s/(/\\ (/g ' | sed ' s/)/\\)/g '


2. Process and rename sed ' s/\\\[\ (. *\) \\\]\\\[\ (. *\) \\\]\\\[\ (. *\) \\\]\\\[\ (. *\) \\\]\\\[\ (. *\) \\\]/MV &.html \1###\2###\3# ##\4###\5.html/e '


The two parts are combined together.

Note: 1, before the second step must be the file name of all the special characters escaped (the first step is to do this)

2. The "&" in the second step of the MV represents the matched string

3. SED usage here is sed ' s/*/mv & */e '

4, the second step of the MV "\1 \2 \3" and so on behalf of the front of the parentheses in the content

Linux Batch file renaming

Related Article

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.