Home > Back-end >  Linux rename multiple files at once
Linux rename multiple files at once

Time:12-29

I run Ubuntu 20.04.

I have to rename several million files everyday.

Is there a single command or some sort of shell expansion I can use to rename all files at once instead of using a for loop?

Filenames look like below

1_new.txt, 2_new.txt, 3_new.txt, 4_new.txt

Expected output

1.txt, 2.txt, 3.txt, 4.txt

CodePudding user response:

This worked for me eventually.

 rename 's/_new//' *_new.txt

I could rename all files through just one command.

  • Related