This article mainly explains how to batch modify file names in linux rename. The content of the explanation in the article is simple and clear, easy to learn and understand. Next, please follow the editor's ideas and slowly deepen, let's study and learn how to batch linux rename Modify the file name!
Syntaxrename 's/src/dst/' *
*
can match any file, you can add restrictions (*.jpg)
This way meets the first strong>When matching strings, replace, and do not replace
Only match the first .txt
rename 's/.txt/.jpg/ ' *
**Adding $** will match the suffix
rename 's/.txt$/.jpg/' *
Add str after the file name of all files
rename 's/$/str/' *
Example rename 's/$/txt/' *
Add txt after the file name
Delete str
rename 's/str$//' *
Examplerename 's/txt$//' *
Delete txt
Add str before the file names of all files
rename 's/^/str/' *
Examplerename 's/^/ hhh' *
Add hhh before the file name
Delete the str< in front of the file name of all files /code>
rename 's/^str//' *
Example rename 's/^hhh//' *
delete all files The string starting with
hhh
after the nameThe string at the end of ^str
str$
rename is divided into two Version, respectively C language version and Perl version
rename original string and new string file name
Example:
When the file to be modified is stored in the file folder under the subdirectory of the current directory, prepare to replace all the files containing linux with unix ones
(1) currently in the file file folder, the statement is rename linux unix *
(2) Currently in the parent directory of the file file, the statement is rename linux unix file/*
rename 's/original string/new string/' file name
Example:
The title is the same as the title of the C language version
(1) Currently in the file folder, the statement is rename 's/linux/unix/' *
(2) Currently in the parent directory of the file file, the statement is rename 's/linux /unix/' file/*
Note: The Perl version is basically used now
Copyright Description:No reproduction without permission。
Knowledge sharing community for developers。
Let more developers benefit from it。
Help developers share knowledge through the Internet。
Follow us