Shell file set weight naming method (Rename!)

  

Linux file single rename generally use mv command, set weight name many people write a simple script, but in fact Linux's rename command can easily achieve the vast majority of heavy Name the

task. The result of man rename is as follows:

NAME

rename - Rename files

SYNOPSIS

rename from to file...

DESCRIPTION< Br>

rename will rename the specified files by replacing the first occurrence of from their name by to.

For example, given the files foo1, ..., foo9, foo10, ..., Foo278, the commands

rename foo foo0 foo?

rename foo foo0 foo??

will turn them into foo001, ..., foo009, foo010, ... , foo278.

And

rename .htm .html *.htm

will fix the extension of your html files.

For example, I have three files :

hs_ok_all_200911.txt

hs_ok_all_a.txt

hs_ok_all_b.txt

I need to change all hs_ok_all to hs

Use

rename hs_ok_all hs hs_ok_all_*

.

So the first parameter of rename is the part to be changed, the second parameter is the changed result, and the third parameter is the file to be changed (including wildcard)

Copyright © Windows knowledge All Rights Reserved