Get the App
SLTechnology News&Howtos  ›  Servers  › 

Use the rename command of linux to change the file name in batch

Shulou Source: shulou.com Published: 2022-06-02 12:45:22 09月16日 Update

This article mainly introduces the use of linux rename command batch change file name, the text is very detailed, has a certain reference value, interested friends must read!

The rename command changes file names in batches using string substitutions.

Original string: The string whose filename needs to be replaced;

Target string: Replace the original characters contained in the file name with the target string;

Files: Specifies the list of files whose names you want to change.

Syntax format: rename [parameter]

Common parameters:

? Can replace a single character * Can replace multiple characters

Reference Example

Rename main1.c to main.c:

[root@linuxcool ~]# rename main1.c main.c main1.c

Rename all files ending in jpg to files ending in png:

[root@linuxcool ~]# rename .jpg .png *.jpg

The folder contains these files: foo1, …, foo9, foo10, …, foo163, rename the files foo1 to foo9 to foo01 to foo09:

[root@linuxcool ~]# rename foo foo0 foo?

Rename all files foo01 to foo99 to foo001 to foo099:

[root@linuxcool ~]# rename foo foo0 foo??

Rename all files foo001 to foo163 to foo0001 to foo0163:

[root@linuxcool ~]# rename foo foo0 foo*

Rename all files foo0100 to foo0163 to foo100 to foo163:

[root@linuxcool ~]# rename foo0 foo0[1]* The above is all the contents of using the Linux rename command to change file names in batches. Thank you for reading! Hope to share the content to help everyone, more relevant knowledge, welcome to pay attention to the industry information channel!

Tags: Files characters filenames strings commands contents parameters goals references values interests single multiple instances guys buddies commonly used folders methods more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL OPPO Reno Linux Huawei NVidia