LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-19-2009, 02:16 PM   #1
zardari7
LQ Newbie
 
Registered: Jul 2009
Posts: 11

Rep: Reputation: 0
How to mass rename files in linux? Please help


OK lets say I have a folder with 500 JPG images and I want to mass rename them all.

they are all ending with *.jpg extension.

Lets say I want the files to have the word "mydomain.com" in it.

like

mydomain.com - anything bla bla.jpg
mydomain.com - anything bla bla 1.jpg
mydomain.com - anything bla bla 2.jpg
mydomain.com - anything bla bla 3.jpg


and so on...



What will the command be?

can someone give an example please.
 
Old 07-19-2009, 02:21 PM   #2
bmarx
Member
 
Registered: Dec 2004
Distribution: Slackware, Arch, FreeBSD
Posts: 202

Rep: Reputation: 34
a google search for "linux mass rename" came up with some answers
 
Old 07-19-2009, 02:22 PM   #3
zardari7
LQ Newbie
 
Registered: Jul 2009
Posts: 11

Original Poster
Rep: Reputation: 0
I did google but could not find any answer that would help me exaclty with my situation.
 
Old 07-19-2009, 02:26 PM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
You can try the rename command, but depending on the distribution you're running on, it can be a different version with a different behavior. However a simple method can be:
Code:
for file in *.jpg
do
  echo mv "$file" "mydomain.com - $file"
done
The echo is just for testing purposes: remove it for actually rename the files.
 
Old 07-19-2009, 02:32 PM   #5
zardari7
LQ Newbie
 
Registered: Jul 2009
Posts: 11

Original Poster
Rep: Reputation: 0
Hi,

I am using CentOS.

That command did not work.

Any other way out?
 
Old 07-19-2009, 03:08 PM   #6
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
Quote:
Originally Posted by zardari7 View Post
Hi,

I am using CentOS.

That command did not work.

Any other way out?
Nope. A for loop is the most straightforward way. What command did you exactly tried? And what is the error message (if any)?
 
Old 07-19-2009, 05:00 PM   #7
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,284

Rep: Reputation: 371Reputation: 371Reputation: 371Reputation: 371
There is also a rename command, e.g.:

Code:
rename "" "mydomain.com - " *.jpg
But the mv command in a for loop should work as well (assuming you remembered to remove the "echo" as you were told).
 
Old 07-19-2009, 06:27 PM   #8
chickenlinux
Member
 
Registered: Mar 2008
Location: Here - Where else?
Distribution: Fedora 12, Arch Linux (updated daily =D)
Posts: 270

Rep: Reputation: 31
I think there's something that's part of XFCE4 I used EXACTLY for this. It's somewhat easy to use, and has a GUI It's got something to do with Thunar, I'm pretty sure. Anyway, it should be part of the CentOS XFCE package, I'll try to figure it out. If you don't mind downloading a whole new desktop environment, (:P Sorry) that might well be the way to go. In the meantime, I'll try to figure out what the name is so you can install just the renamer.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
mass rename files tiaratiara Linux - Newbie 3 02-27-2009 09:49 PM
LXer: Mass-Rename Files Using an Easy CLI Method LXer Syndicated Linux News 0 07-07-2008 07:20 PM
mass rename files cope Programming 4 10-28-2007 12:33 PM
BASH USAGE: mass files rename sirpelidor Linux - General 8 09-20-2005 01:36 AM
Mass Rename wickdgin Linux - Newbie 2 04-13-2003 03:29 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:59 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration