LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to mass rename files in linux? Please help (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-mass-rename-files-in-linux-please-help-741213/)

zardari7 07-19-2009 01:16 PM

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.

bmarx 07-19-2009 01:21 PM

a google search for "linux mass rename" came up with some answers :)

zardari7 07-19-2009 01:22 PM

I did google but could not find any answer that would help me exaclty with my situation.

colucix 07-19-2009 01:26 PM

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.

zardari7 07-19-2009 01:32 PM

Hi,

I am using CentOS.

That command did not work.

Any other way out?

colucix 07-19-2009 02:08 PM

Quote:

Originally Posted by zardari7 (Post 3612885)
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)?

btmiller 07-19-2009 04:00 PM

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).

chickenlinux 07-19-2009 05:27 PM

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.


All times are GMT -5. The time now is 12:07 PM.