usert4jju7
usert4jju7

Reputation: 1813

Linux rename multiple files at once

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

Upvotes: 0

Views: 209

Answers (2)

Rogoit
Rogoit

Reputation: 91

I also had this challenge to rename my files for a better seo name and found zmv on the oh-my-zsh linux terminal to do it.

For this i published a live coding video on YouTube

Upvotes: 1

usert4jju7
usert4jju7

Reputation: 1813

This worked for me eventually.

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

I could rename all files through just one command.

Upvotes: 1

Related Questions