GeekAfterHours
  • How To
    • [POF Update] Plenty of Fish Search Without Registering
    • How to Hide/Unhide Text Messages on iPhone?
  • Login Guide
    • wmlink/2step on a Walmart
    • DISH Anywhere
    • Walmart GTA Portal
    • Uinteract Login
    • myOLSD Portal
    • HYvee Connect Login
    • Paycor Login
    • Dayforce Trader Joes Login
    • My Office Tupperware Login
    • MyHR BFUSA MyBridgeStone Portal Login
    • AHRebates.com Rebate Form Submission & Reward Guide
    • MyTHDHR Your Schedule Login
    • OurTime Login
    • MyHTSpace Login
    • UKG Pro Ultipro Login
  • Gadgets
    • Best Projectors for Gaming
    • Best Cardstock Printers
    • Best Smartwatches for Texting
    • Best Headphones for Music Production Artists
    • Best 3D Printer for Cosplay
    • Best Tablet for OSU
    • Best Power Supply for GTX 1080 Ti
    • Best Monitor for GTX 1070
    • Best Walkie Talkie
    • Best Satellite Phone for Backpacking
  • Laptops
    • Best Laptops for Zoom Meetings
    • Best Laptops for Medical Students
    • Best Laptops for Online Schooling
    • Best Laptops for College Students
    • Best IPS Screen Laptops
    • Best Laptops for Machine Learning
    • Best Laptops for Revit Software
    • Best Laptops with Microsoft Office Bundle
    • Best Laptops for Adobe Creative Cloud
    • Best Laptops for Stock Trading
    • Best Laptops for League of Legends
    • Best Laptops for Mechanical Engineering Students
    • Best Laptops for Cricut Maker Cutting Machine
    • Best Laptops for Accounting
  • Guides
    • Best YouTube to Mp4 Converters Online
No Result
View All Result
  • How To
    • [POF Update] Plenty of Fish Search Without Registering
    • How to Hide/Unhide Text Messages on iPhone?
  • Login Guide
    • wmlink/2step on a Walmart
    • DISH Anywhere
    • Walmart GTA Portal
    • Uinteract Login
    • myOLSD Portal
    • HYvee Connect Login
    • Paycor Login
    • Dayforce Trader Joes Login
    • My Office Tupperware Login
    • MyHR BFUSA MyBridgeStone Portal Login
    • AHRebates.com Rebate Form Submission & Reward Guide
    • MyTHDHR Your Schedule Login
    • OurTime Login
    • MyHTSpace Login
    • UKG Pro Ultipro Login
  • Gadgets
    • Best Projectors for Gaming
    • Best Cardstock Printers
    • Best Smartwatches for Texting
    • Best Headphones for Music Production Artists
    • Best 3D Printer for Cosplay
    • Best Tablet for OSU
    • Best Power Supply for GTX 1080 Ti
    • Best Monitor for GTX 1070
    • Best Walkie Talkie
    • Best Satellite Phone for Backpacking
  • Laptops
    • Best Laptops for Zoom Meetings
    • Best Laptops for Medical Students
    • Best Laptops for Online Schooling
    • Best Laptops for College Students
    • Best IPS Screen Laptops
    • Best Laptops for Machine Learning
    • Best Laptops for Revit Software
    • Best Laptops with Microsoft Office Bundle
    • Best Laptops for Adobe Creative Cloud
    • Best Laptops for Stock Trading
    • Best Laptops for League of Legends
    • Best Laptops for Mechanical Engineering Students
    • Best Laptops for Cricut Maker Cutting Machine
    • Best Laptops for Accounting
  • Guides
    • Best YouTube to Mp4 Converters Online
No Result
View All Result
GeekAfterHours
No Result
View All Result
Home How To

How to Rename Multiple Linux Files at Once?

GeekyGuy by GeekyGuy
August 24, 2021
Rename Linux File
Table of contents
  • Method 1 – MMV Command
  • Method 2 – Pre-Installed Rename Command
  • Method 3 – Get Help of Renameutils
  • Method 4 – Use Vimv to Rename Multiple Linux Files
  • Method 5 – Give  Try to Emacs
  • Method 6 – Use Thunar File Manager
    • Conclusion

Today we are going to guide you on how to rename Linux file with some simple methods.

You might already be aware about the mv command used to rename or move folders at Linux. It is also used to rename Linux directory or Unix file.

But the mv command cannot support renaming numerous files at once.

It only supports renaming one file at a time and this can be time consuming if you want to rename multiple files at Linux.

All the methods that we are going to discuss about are tested in Ubuntu and will work on all Linux operating systems.

So, let us begin and understand the process of renaming files at once in Linux.

Read Also: Best Linux Distros for Gaming, Developers and Security in 2020

Method 1 – MMV Command

In Linux, you can move, copy, rename and append files in bulk using the mmv utility.

It is done by the standard wildcards in Unix-like operating systems.

Let us consider an example of the following files whose name you wish to change.

Ex: a1.txt a2.txt a3.txt

If you wish to rename all files that starts with letter “a” to “b” then this can be done manually but if you have 100 of files then it can take to much time in renaming all.

So, in this case we are going to use the mmv command.

Simply run the below command to rename all files starting with letter “a” to “b”.

Command: $ mmv a\* b\#1

Now you can go and check if all the files starting from the letter ‘a’ have been renamed to b1.txt, b2.txt, b3.txt.

So, the main job of mmv command is to look for filenames starting with letter ‘a’ and rename it.

Wildcards such as ‘*’, ‘?’, ‘[]‘ are used to match 1 or more subjective characters.

It is important to remember not to escape the wildcard characters, or else they will be extended by the shell and mmv command will not be able to understand them.

The wildcard index is ‘#1′ in the ‘to’ pattern.

In the above example we only have one wildcard that is the reason we write #1.

Renaming files to different extension is also possible like, .txt files to .doc file format.

Simply run the below command:

$ mmv \*.txt \#1.doc

In case you have the following files:

$ ls

abcd1.txt abcd2.txt abcd3.txt

Here if you want to change the “abc” with “xyz” then follow the below command:

$ mmv ‘*abc*’‘#1xyz#2’

The result should be like this

$ ls

xyzd1.txt xyzd2.txt xyzd3.txt

One more feature of the mmv command is that you can print output instead of renaming the files using -n option.

Example:

$ mmv -n a\* b\#1

a1.txt -> b1.txt

a2.txt -> b2.txt

a3.txt -> b3.txt

So, these were the simple steps to follow while using the mmv command to rename file Linux command.

Method 2 – Pre-Installed Rename Command

In this option we will be using the rename utility for name replacement. This command mostly comes preinstalled in most Unix-like operating systems.

In case it is not available then run the below command to install it on Debian-based systems:

$ sudo apt install rename

Let’s take the names of the following files for example:

$ ls

abcd1.txt abcd2.txt abcd3.txt

Now run the below command to replace the first occurrence of abc with xyz.

$ rename ‘s/abc/xyz/’ *

The result should look like

$ ls

xyzd1.txt xyzd2.txt xyzd3.txt

Many times, you might just need to print instead of renaming files, in that case using the -n flag to display which renames would occur without performing them:

$ rename -n ‘s/abc/xyz/’ *

rename(abcd1.txt, xyzd1.txt)

rename(abcd2.txt, xyzd2.txt)

rename(abcd3.txt, xyzd3.txt)

Notice how the above commands did not make changes, instead just showing you the displays, which renames would occur.

By using the -f flag you can impose renaming task even if the operation would overwrite current files.

Use the below command to use -f flag.

$ rename -f ‘s/abc/xyz/’ *

If you don’t wish to overwrite files, then you can also convert them from upper or lowercase letters or vice versa.

This is done to prevent the “already exists” errors.

Use the below commands to rename filename to lower case:

$ rename ‘y/a-z/A-Z/’ *

The changes made will look somewhat like this:

$ ls

ABCD1.TXT

ABCD2.TXT

ABCD3.TXT

So, these letters have been changed from lowercase to uppercase.

Method 3 – Get Help of Renameutils

The renameutils method is used on set of programs designed to batch rename file command line and directories faster and easier.

The way has the following programs:

  1. qmv (quick move)
  2. qcp (quick copy)
  3. imv (interactive move)
  4. icp (interactive copy)
  5. deurlname (delete URL)

We will discuss the first two.

For this first you need to install renameutils.

It is available in the default repositories of most Linux distributions.

Run the following command to install Arch-based system:

$ sudopacman -Syurenameutils

Debian-based systems:

$ sudo apt install renameutils

qmv (quick move)

This will let edit the files by opening them in your default text editor.

Let’s consider the file name as ‘Labtech’

Run the following command:

$ ls Labtech/

abcd1.txt abcd2.txt abcd3.txt

To rename the filenames in the ‘Labtech’ directory, simply run:

$ qmv Labtech/

Now go back and preview the names of the file and if they are changed or not.

You will see two columns, after you open the files.

The left one will show the source filename and the right one will show destination names.

Here you can simply rename all the output names on the right side.

After you are done renaming them, do not forget to save, and quit the file.

qcp (quick copy)

This program is quite like qmv, but instead it copies files rather than renaming them.

But do not worry it also keeps both original and replicate files.

Command:

$ qcp Labtech/

Method 4 – Use Vimv to Rename Multiple Linux Files

In this method we use vimv. It is a command line utility to rename many files using Vim editor.

To install Vimv go to:

$ git clone https://github.com/thameera/vimv.git

Next copy vimv binary to your $PATH, for example /usr/local/bin/.

Command:

$ sudo cp vimv/vimv /usr/local/bin/

Lastly, execute it

$ sudochmod +x /usr/local/bin/vimv

Now you can go to the directory and run the following command to edit the filenames.

Find the filenames in Vi editor.

To switch to interactive mode simply press i button, then edit the filenames as the way you change text in Vi editor.

After you are done with editing press ESC key and type :wq to save and exit.

Check the files inside directory that if they are renamed or not.

Method 5 – Give  Try to Emacs

In this method we are going to use Emacs.

If you have an operating system with Emacs editor, then the following steps can be performed.

First open your Emacs editor.

Next press Alt+x and type “dired” then hit the Enter button to switch to wdired-mode.

Enter to the desired directory that has the files to rename and hit ENTER key.

Next to switch to read-write mode, press Ctrl+x and Ctrl+q.

Now you can rename the files and after you are done, press Ctrl+c and Ctrl+c twice to save the changes.

In case you want to abort the changes, press Ctrl+c and Ctrl+k.

Method 6 – Use Thunar File Manager

You can do this method by using Thunar file manager. This manager has a built-in bulk rename option by default.

It is available in the default repositories of most of the Linux distributions.

Run the following to install Arch-based system:

$ sudopacman -S thunar

On RHEL, CentOS:

$ sudo yum install thunar

On Fedora:

$ sudodnf install thunar

On openSUSE:

$ sudozypper install thunar

On Debian, Ubuntu, Linux Mint:

$ sudo apt-get install thunar

After the installation, you can start bulk rename utility from the application launcher or the menu.

If you want to launch it from Terminal, run the following command:

$ thunar -B

Now you will see the page Bulk Rename- Rename Multiple Files

With options like, Insert Date or Time, Numbering, Insert or Overwrite, Uppercase / Lowercase, Remove Characters, Search & Replace.

Select the option that you wish to choose and after editing you will be able to preview it also.

Now, click on Rename Files option to save.

Conclusion

So, here was the full guide on how you can rename file Linux command. The whole guide will show you different methods that you can use to rename multiple files at once on Linux.

Also go through all the commands for different methods and use them effectually.

I hope after reading the article you will have enough knowledge for renaming files using all the 6 methods.

GeekyGuy

GeekyGuy

Geeky Guy is inspired by innovative technology taking shape around the world and this is what motivate him to start Geek After Hours, a tech blog featuring how to guides about computer, laptops, mobiles, software, and gadgets. He also like to write reviews about technology products with an aim to help you make better buying decisions.

Related Posts

MacBook Won’t Turn on or Boot up? 4 Troubleshooting Tips to Help You Out 

MacBook Won’t Turn on or Boot up? 4 Troubleshooting Tips to Help You Out 

by GeekyGuy
May 20, 2022
0

...

How to make dissertation writing easier?

How to make Dissertation Writing Easier?

by GeekyGuy
May 15, 2022
0

...

read your spouse messages

Is it Possible to Read My Spouse’s Messages Secretly?

by GeekyGuy
April 30, 2022
0

...

How to Copy and Paste on MAC

How to Copy and Paste on Mac (Manual and Keyboard Shortcuts)

by GeekyGuy
March 24, 2022
0

...

How to Change your Name on Facebook

How to Change your Name on Facebook (Mobile & PC)

by GeekyGuy
March 22, 2022
0

...

gah-logo

Affiliate Disclaimer

Geek After Hours is a participant in the Amazon Services LLC Associates Program which is an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com.

Best Cameras

Best Low Light Video Cameras (Value for Money)

10 Best Cameras for Filmmaking on a Budget

5 Best Cameras for Stop Motion Photography (Expert Choice)

5 Best 16mm Lens Cameras (Tested by Professional Photographers)

4 Best Ice Fishing Cameras (Expert’s Opinion)

13 Best Video Cameras for Sports (Experts Pick)

Best Laptops

10 Best Laptops Under $800

7 Best Gaming Laptops Under $600

13 Best Gaming Laptops Under $1500 (Top Picks)

Best Gaming Laptops Under 2000 Dollars (Top Picks)

5 Best Laptops for Streaming Live Sports

9 Best Laptops for Accounting (Trusted by Top Accountants)

  • About Us
  • Contact Us
  • Disclaimer
  • Privacy Policy
  • Terms
  • Write for us

© 2022 GeekAfterHours. All Rights Reserved

No Result
View All Result
  • How To
  • Login Guide
  • Gadgets
  • Laptops
  • Guides
  • UKG PRO ULTIPRO

© 2022 GeekAfterHours. All Rights Reserved