LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 03-31-2005, 04:40 AM   #1
Sapient
Member
 
Registered: Oct 2003
Location: San Luis Obispo, CA
Distribution: SuSE
Posts: 196

Rep: Reputation: 30
Changing global file names.


Easy question.

What is the command for changing the file extensions on all files in a directory?

Example:

rename *.php *.php4

In Linux it is the mv command, however, there has to be a way to change all files as specified???



Thanks
 
Old 03-31-2005, 04:58 AM   #2
slackie1000
Senior Member
 
Registered: Dec 2003
Location: Brasil
Distribution: Arch
Posts: 1,037

Rep: Reputation: 46
hi there,

try that:
Code:
#!/bin/sh
for i in `ls *php`
do
 mv $i $i4
done
regards

slackie1000
 
Old 03-31-2005, 05:01 AM   #3
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

One minor thing about the solution slackie1000 gave:

mv $i $i4
Should be
mv $i ${i}4

$i4 is not he same as ${i}4
 
Old 03-31-2005, 05:04 AM   #4
Sapient
Member
 
Registered: Oct 2003
Location: San Luis Obispo, CA
Distribution: SuSE
Posts: 196

Original Poster
Rep: Reputation: 30
Thanks guys for the response.


Is this perl script?
 
Old 03-31-2005, 05:04 AM   #5
slackie1000
Senior Member
 
Registered: Dec 2003
Location: Brasil
Distribution: Arch
Posts: 1,037

Rep: Reputation: 46
Quote:
Originally posted by druuna
Hi,

One minor thing about the solution slackie1000 gave:

mv $i $i4
Should be
mv $i ${i}4

$i4 is not he same as ${i}4
* slackie1000 hits his head in the wall *

of course!
thanks druuna...

regards

slackie1000
 
Old 03-31-2005, 05:05 AM   #6
slackie1000
Senior Member
 
Registered: Dec 2003
Location: Brasil
Distribution: Arch
Posts: 1,037

Rep: Reputation: 46
Quote:
Originally posted by Sapient
Thanks guys for the response.


Is this perl script?
no

shell script..

regards

slackie1000
 
Old 03-31-2005, 05:10 AM   #7
Sapient
Member
 
Registered: Oct 2003
Location: San Luis Obispo, CA
Distribution: SuSE
Posts: 196

Original Poster
Rep: Reputation: 30
Thanks guys, this worked great.
 
  


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
changing subject title names doesn't work on forums A6Quattro LQ Suggestions & Feedback 2 10-17-2005 12:01 PM
Samba keeps changing user names/domains dougnc Linux - Networking 2 08-22-2005 02:13 PM
internal disk /dev names keep changing! aemee Linux - Enterprise 3 04-04-2005 08:56 PM
Changing How Host Names are Looked Up civicsi Linux - Newbie 2 04-24-2004 07:18 AM
Changing Mount Names lehumphr Linux - Hardware 2 09-12-2003 10:21 AM

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

All times are GMT -5. The time now is 01:27 AM.

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