There are several ways, but using rename will probably be the easiest.

Using one version of rename (Perl's rename):

rename 's/^fgh/jkl/' fgh*

Using another version of rename (same as Judy2K's answer):

rename fgh jkl fgh*

You should check your platform's man page to see which of the above applies.

Answer from Stephan202 on Stack Overflow
🌐
Batsov
batsov.com › articles › 2020 › 11 › 21 › rename-multiple-files-in-linux
Rename Multiple Files in Linux | (think)
November 21, 2020 - Interestingly enough, Zsh provides a much simpler and way more powerful way to tackle mass rename, via the zmv utility it bundles: While zmv doesn’t use regular expressions, its matching and substitution functionality should cover pretty much everything you decide to throw at it. Note that zmv is usually not enabled by default and you might have to load it manually before using it: Notice also that in the first argument of zmv you’re specifying both the search pattern for files and substitution groups you can use in the second argument.
Discussions

How to bulk rename multiple files?
There are many ways. You could learn how bash string substitution works and mv files to new names. You could use rename which takes substitute parameters similar to sed. You could install Thunar file manager and use its excellent Bulk Rename graphical program. This is the sort of practical useful exercise which makes you better and more self-sufficient at using Linux so I encourage you to research this and find a solution yourself instead of waiting for someone to spoonfeed you an answer. More on reddit.com
🌐 r/linuxquestions
27
3
September 15, 2024
Rename multiple files with mv to change the extension - Unix & Linux Stack Exchange
I want to rename files to change their extension, effectively looking to accomplish mv *.txt *.tsv But when doing this I get : *.tsv is not a directory I find it somewhat strange that the firs... More on unix.stackexchange.com
🌐 unix.stackexchange.com
January 26, 2015
Rename multiple files by replacing a particular pattern in the filenames using a shell script - Stack Overflow
Write a simple script that will automatically rename a number of files. As an example we want the file *001.jpg renamed to user defined string + 001.jpg (ex: MyVacation20110725_001.jpg) The usage for More on stackoverflow.com
🌐 stackoverflow.com
sed - how to rename multiple files by replacing string in file name? this string contains a "#" - Unix & Linux Stack Exchange
There are two common rename utilities ... from the Linux Kernel Organization. Your link is to the rename C function from the GNU standard library. ... /g means global search, i.e. once it finds and replaces an instance of the string, it will keep searching the filename for more ... More on unix.stackexchange.com
🌐 unix.stackexchange.com
🌐
LinuxConfig
linuxconfig.org › home › how to rename multiple files on linux
Rename Multiple Files on Linux with mv, rename, mmv
September 22, 2025 - Renaming files on Linux systems is usually handled by the mv (move) command. The syntax is just mv old.txt new.txt. Simple enough, but what if we have multiple files that need to be renamed at once, even hundreds of them?
Top answer
1 of 8
213

I use rename all the time. It is pretty simple, but hopefully you know basic regex:

rename "s/SEARCH/REPLACE/g"  *

This will replace the string SEARCH with REPLACE in every file (that is, *). The /g means global, so if you had a SEARCH_SEARCH.jpg, it would be renamed REPLACE_REPLACE.jpg. If you didn't have /g, it would have only done substitution once, and thus now named REPLACE_SEARCH.jpg. If you want case-insensitive, add /i (that would be, /gi or /ig at the end).

With regular expressions, you can do lots more.

Note that this rename is the prename (aka Perl rename) command, which supports complete Perl regular expressions. There is another rename which uses patterns, and is not as powerful. prename used to be installed by default on Ubuntu (along with Perl), but now you may have to do:

sudo apt install rename

Here are a few examples:

Prefix

Add:

rename 's/^/MyPrefix_/' * 
  • document.pdf renamed to MyPrefix_document.pdf

Remove:

Also you can remove unwanted strings. Let's say you had 20 MP3 files named like CD RIP 01 Song.mp3 and you wanted to remove the "CD RIP" part, and you wanted to remove that from all of them with one command.

rename 's/^CD RIP //' *
  • CD RIP 01 Song.mp3 to 01 Song.mp3

Notice the extra space in '^CD RIP ', without the space all files would have a space as the first character of the file. Also note, this will work without the ^ character, but would match CD RIP  in any part of the filename. The ^ guarantees it only removes the characters if they are the beginning of the file.

Suffix

Add:

rename 's/$/_MySuffix/' *
  • document.pdf renamed to document.pdf_MySuffix

Change:

rename 's/\.pdf$/.doc/' *

will change Something.pdf into Something.doc. (The reason for the backslash is, . is a wildcard character in regexp so .pdf matches qPDF whereas \.pdf only matches the exact string .pdf. Also very important to note, if you are not familiar with BASH, you must put backslashes in SINGLE quotes! You may not omit quotes or use double quotes, or bash will try to translate them. To bash \. and "\." equals .. (But double-quotes and backslashes are used, for example "\n" for a newline, but since "\." isn't a valid back escape sequence, it translates into .)

Actually, you can even enclose the parts of the string in quotes instead of the whole: 's/Search/Replace/g' is the same as s/'Search'/'Replace'/g and s/Search/Replace/g to BASH. You just have to be careful about special characters (and spaces).


I suggest using the -n option when you are not positive you have the correct regular expressions. It shows what would be renamed, then exits without doing it. For example:

rename -n s/'One'/'Two'/g *

This will list all changes it would have made, had you not put the -n flag there. If it looks good, press Up to go back, then erase the -n and press Enter (or replace it with -v to output all changes it makes).

Note: Ubuntu versions above 17.04 don't ship with rename by default, however it's still available in the repositories. Use sudo apt install rename to install it

2 of 8
22

Try pyrenamer.

It's not integrated with nautilus, but it gets the job done. Here is a review.

Thunar (part of XFCE) also has a renamer that you can run separately.

🌐
PhoenixNAP
phoenixnap.com › home › kb › sysadmin › how to rename files in linux
How to Rename Files in Linux (Multiple Options and Examples)
December 9, 2025 - Instead of the find command, you can use the mv command as a part of a Bash for loop to rename multiple files. Using the same example as in the section above, do the following: 1. Create and open a Bash script file via a text editor such as ...
🌐
nixCraft
cyberciti.biz › nixcraft › tutorials › linux › linux rename multiple files at a shell prompt
Linux Rename Multiple Files At a Shell Prompt - nixCraft
February 26, 2025 - The syntax is: $ rename oldname ... $ zmv '*' '${(L)f}' See zshwiki for more info on zmv. You can use the mmv command to move/copy/append/link multiple files....
Find elsewhere
🌐
TecMint
tecmint.com › home › linux commands › rename – a command line tool for renaming multiple files in linux
A Command Line Tool For Renaming Multiple Files in Linux
May 24, 2024 - Linux comes with a very powerful built-in tool called rename, which is used to rename multiple files or groups of files, convert filenames to lowercase, convert filenames to uppercase, and overwrite files using Perl expressions.
Top answer
1 of 6
50

I know this doesn't answer your question, but in case you were looking for another way to rename the files compared to your work-around loop, why not use find? I have used this command many times to replace file extensions in large directories with hundreds of thousands of files in it. This should work on any POSIX-compliant system:

find . -name "*.gappedPeak" -exec sh -c 'mv "{1%.gappedPeak}.bed"' _ {} \;

Command Breakdown:

  1. '.' => search path starting at current directory marked by ' . '

  2. -name => set find match name (in this case all files that end with .gappedPeak)

  3. -exec => execute the following command on every match

  4. sh -c => 'exec' creates an independent shell environment for each match

  5. mv "{1%.gappedPeak}.bed" => mv first variable (denoted by $1), which is the current file name, to new name. Here I do a substring match and delete; so take first var again, $1 and use % to delete .gappedPeak from the string. The .bed at the end just concatenates the remaining variable, which in the example below would now be testNumber, with .bed, creating the new testNumber.bed filename.

  6. The underscore is a placeholder for $0

  7. The {} is replaced by each (*.gappedPeak) filename found by the find command, and becomes $1 to the sh command.

  8. \; marks the end of the -exec command.  You can also use ';' or ";".

Example:

[user@before]# ls -lh
total 0
-rw-r--r--. 1 root root 0 Jan 26 11:40 test1.gappedPeak
-rw-r--r--. 1 root root 0 Jan 26 11:40 test2.gappedPeak
-rw-r--r--. 1 root root 0 Jan 26 11:40 test3.gappedPeak
-rw-r--r--. 1 root root 0 Jan 26 11:40 test4.gappedPeak
-rw-r--r--. 1 root root 0 Jan 26 11:40 test5.gappedPeak

[user@after]# ls -lh
total 0
-rw-r--r--. 1 root root 0 Jan 26 11:40 test1.bed
-rw-r--r--. 1 root root 0 Jan 26 11:40 test2.bed
-rw-r--r--. 1 root root 0 Jan 26 11:40 test3.bed
-rw-r--r--. 1 root root 0 Jan 26 11:40 test4.bed
-rw-r--r--. 1 root root 0 Jan 26 11:40 test5.bed
2 of 6
33

This answer won't help you change the extension, but it will help you understand why your command is not doing what you expect.

When you issue the command:

mv *.txt *.tsv

the shell, lets assume bash, expands the wildcards if there are any matching files (including directories). The list of files is passed to the program, here mv. If no matches are found the unexpanded version is passed.

Again: the shell expands the patterns, not the program.


Loads of examples is perhaps best way to understand why this won't work. So here we go:

Example 1:

$ ls
file1.txt file2.txt

$ mv *.txt *.tsv

Now what happens on the mv line is that the shell expands *.txt to the matching files. As there are no *.tsv files that is not changed.

The mv command is called with two special arguments:

  • argc: Number of arguments, including the program.
  • argv: An array of arguments, including the program as first entry.

In the above example that would be:

 argc = 4
 argv[0] = mv
 argv[1] = file1.txt
 argv[2] = file2.txt
 argv[3] = *.tsv

The mv program checks to see if the last argument, *.tsv, is a directory. As it is not, the program can not continue as it is not designed to concatenate files. (combine all the files into one.) Nor can it create directories on a whim.

As a result, it aborts and reports the error:

mv: target ‘*.tsv’ is not a directory

Example 2:

Now if you instead say:

$ mv *1.txt *.tsv

The mv command is executed with:

 argc = 3
 argv[0] = mv
 argv[1] = file1.txt
 argv[2] = *.tsv

Now, again, mv checks to see if *.tsv exists. As it does not, the file file1.txt is moved to *.tsv. That is: the file is renamed to *.tsv with the asterisk and all.

$ mv *1.txt *.tsv
‘file1.txt’ -> ‘*.tsv’

$ ls
file2.txt *.tsv

Example 3:

If you instead said:

$ mkdir *.tsv
$ mv *.txt *.tsv

The mv command is executed with:

 argc = 3
 argv[0] = mv
 argv[1] = file1.txt
 argv[1] = file2.txt
 argv[2] = *.tsv

As *.tsv now is a directory, the files end up being moved there.


Now: using commands like some_command *.tsv when the intention is to actually keep the wildcard one should always quote it. By quoting you prevent the wildcards from being expanded if there should be any matches. E.g. say mkdir "*.tsv".

Example 4:

The expansion can further be viewed if you do, for example:

$ ls
file1.txt file2.txt

$ mkdir *.txt
mkdir: cannot create directory ‘file1.txt’: File exists
mkdir: cannot create directory ‘file2.txt’: File exists

Example 5:

Now: the mv command can and does work on multiple files. But if there are more than two the last one has to be a target directory. (Optionally you can use the -t TARGET_DIR option, at least for GNU mv.)

So this is OK:

 mv *.txt *.tsv foo

Here mv would be called with:

 argc = 7
 argv[0] = mv
 argv[1] = b1.tsv
 argv[2] = b2.tsv
 argv[3] = f1.txt
 argv[4] = f2.txt
 argv[5] = f3.txt
 argv[6] = foo

and all the files end up in the directory foo.


As for your links. You have provided one (in a comment), where mv is not mentioned at all, but rename. Do you have more links or man pages that you could share where your claim is expressed?

🌐
Ubuntu Community
help.ubuntu.com › stable › ubuntu-help › files-rename-multiple.html.en
Rename multiple files
Select two or more files in Files. Press F2 or right-click on the selection and pick Rename.
🌐
Linux Mint Forums
forums.linuxmint.com › board index › main edition support › beginner questions
[SOLVED] Rename multiple files - Linux Mint Forums
July 18, 2020 - I believe there is an even easier way in Nemo/File Manager. Just select all the files (ctrl+a), then right click, select rename, then click "+ Add", and choose whatever number option you like.
🌐
Linuxize
linuxize.com › home › linux commands › how to rename files and directories in linux
How to Rename Files and Directories in Linux | Linuxize
March 12, 2026 - The mv command (short for move) is used to rename or move files from one location to another. The syntax for the mv command is as follows: ... The SOURCE can be one or more files or directories, and DESTINATION can be a single file or directory.
🌐
OSTechNix
ostechnix.com › home › linux tips & tricks › 8 methods to rename multiple files at once in linux
How To Rename Multiple Files At Once In Linux - OSTechNix
November 13, 2025 - See? It is very simple to rename multiple files at once. The Thunar file manager has built-in bulk rename option by default. Thunar is available in the default repositories of most Linux distributions.
🌐
RoseHosting
rosehosting.com › home › how to rename multiple files on linux
How to Rename Multiple Files on Linux | RoseHosting
December 5, 2022 - See ‘man magic’ for the details on linux/unix filetypes. Reply ... It is really useful example. Sometimes you may need to change a file extension from .txt to .html, .txt to .text , etc… Reply · The rename utility is one way to rename multiple files, but you have overlooked a better alternative — mmv (multiple move) — which also have an important safety feature of not overwriting files due to collisions arising from syntax errors in the target specification.