LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-19-2005, 04:46 PM   #1
Lleb_KCir
Senior Member
 
Registered: Nov 2003
Location: Orlando FL
Distribution: Debian
Posts: 1,765

Rep: Reputation: 45
rename a group of files to a single extention


without changing the name of the file...

i have a group of .JPG files in with a directory of .jpg files, i just want to mv the .JPG to .jpg is there a way to do this without renaming or touching every single .JPG file?
 
Old 02-19-2005, 05:04 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
http://www.linuxquestions.org/questi...32#post1348432

should cover you, and if that's too indepth, you should be able to take a few pointers from my script (or the other exampels)
 
Old 02-19-2005, 05:06 PM   #3
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
Here's one way to do it...
Code:
#!/bin/bash
dir=/home/images
ls $dir | grep -e "JPG" | \
while read i; do
j=`echo -n "$i" | sed -e 's/JPG$/jpg/'`
mv "$dir/$i" "$dir/$j"
done
 
Old 02-19-2005, 06:28 PM   #4
Lleb_KCir
Senior Member
 
Registered: Nov 2003
Location: Orlando FL
Distribution: Debian
Posts: 1,765

Original Poster
Rep: Reputation: 45
ok that is a bit more complicated then i was thinking, hoping it would be, how do i do that? just log in as root and type !/bin/bash and hit the enter key after each line you have...???

mega newbie to any kind of scripting.
 
Old 02-19-2005, 06:36 PM   #5
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
no that's a bash script. copy the verbatim into a file, and run it.
 
Old 02-19-2005, 10:57 PM   #6
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
Guys... overkill...

Code:
rename ".JPG" ".jpg" *.JPG
That is, unless I'm overlooking something in the problem.
 
Old 02-19-2005, 11:11 PM   #7
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
Well poo! guess I got caught up in the script thingy. That actually had a more meaningful use previously and I just changed a few things to make it fit.
 
Old 02-19-2005, 11:20 PM   #8
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
Hehehe... honestly, I thought I was going to receive a swift back-hand response for my insolence. I kept thinking, "There has got to be a reason they're suggesting a script... maybe a follow-up question from a previous thread??"

I've seen messages from you and acid_kewpie before, and you guys pretty much nail things right on the head: straight and to the point. So I was prepared to nurse my ego because there had to be something I was missing
 
Old 02-19-2005, 11:34 PM   #9
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
Quote:
honestly, I thought I was going to receive a swift back-hand response for my insolence.
To your room! And no tv for a month.
 
Old 02-20-2005, 12:40 AM   #10
Lleb_KCir
Senior Member
 
Registered: Nov 2003
Location: Orlando FL
Distribution: Debian
Posts: 1,765

Original Poster
Rep: Reputation: 45
Quote:
Originally posted by Dark_Helmet
Guys... overkill...

Code:
rename ".JPG" ".jpg" *.JPG
That is, unless I'm overlooking something in the problem.
cheers, simplisity at its best. now that is something i can do *grins*

thanks all for the wounderful responses on this question.
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I rename a lot of files with a single command? pujolasdf Linux - Software 4 07-20-2005 05:27 AM
rename files allelopath Linux - General 5 07-05-2005 03:00 AM
Can not rename files. Maximus2000 Linux - General 0 04-22-2004 01:36 PM
What is the extention of Linux executable files. AskMe Linux - Newbie 4 10-22-2003 01:55 PM
how do i group multiple global ip addresses on a single network iterface? shinacalypse Linux - Networking 3 09-08-2003 06:07 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:15 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
Open Source Consulting | Domain Registration