File batch rename Linux Ubuntu

Source: Internet
Author: User
Ls *. Jad | xargs-N 1-I-t MV {}{}. Java

A and suffix

1. problem: a directory contains a large number of files named by date, some of which have suffixes and some end with dots, such as 20020101., 20020102 .,......, 20020101. TD, 20020102.td.pdf ......
Requirement: add the suffix. Ts to all vertices.
My method:
#! /Bin/bash
For files in 'ls *.'
Do
MV $ files 'echo "$ filests "'
Done

2. Same as above

MV $ files $ {files} TS

3. Same as above

MV $ files '$ files. Ts | SED's //.//''

4. File => file.txt

MV $ files saved files.txt

5. *. 04 => * 04.txt

MV $ files $ (echo audio files.txt | SED's //. // 1 ')

Or

MV $ files 'echo too many files0000.txt | SED's //. // 1''

B. Change the suffix (. Old =>. New)

1. Rename

Rename. Old. New *

2.
MV $ files $ {file %. Old}. New

3.
MV $ files 'echo $ files | tr. Old. new'

4.
MV $ files 'echo $ files | SED's //. Old //. New /''

C remove the suffix (*. dat => *)

1. Mv $ files 'echo $ files | SED's //. dat //''

2. Mv $ files 'echo $ files | tr. dat (4 spaces )'

D. Change the prefix (Re * => UN *)

1. Mv $ files UN $ {$ files # re}

2. Mv $ files 'echo $ files | tr re UN'

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.