Renaming the File in UNIX | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Renaming the File in UNIX

UNIX for Dummies Questions & Answers


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 08-19-2008
mazhar803 mazhar803 is offline
Registered User
 
Join Date: Sep 2007
Last Activity: 29 August 2008, 7:36 AM EDT
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Error Renaming the File in UNIX

I have many files in a particular folder(all ending with extension .F1.Test). I need a unix command that will change my file extension from .F1.Test to .csv

I tried giving the command as "ren sample.F1.Test sample.csv", but i got the file as "sample.F1.csv"
Example : I have the filename (sample.F1.Test and test.F1.Test), so after the unix command it should be renamed to (sample.csv and test.csv). Please let me know the unix command to convert the above file extension.
Sponsored Links
    #2  
Old 08-19-2008
prashant43's Avatar
prashant43 prashant43 is offline
Registered User
 
Join Date: Jan 2008
Last Activity: 25 August 2011, 6:36 PM EDT
Location: Phoenix
Posts: 32
Thanks: 1
Thanked 0 Times in 0 Posts
Try
mv sample.F1.Test sample.csv
mv test.F1.Test test.csv
Sponsored Links
    #3  
Old 08-19-2008
vidyadhar85's Avatar
vidyadhar85 vidyadhar85 is offline Forum Advisor  
The Tutor
 
Join Date: Jun 2008
Last Activity: 9 April 2014, 1:31 AM EDT
Location: INDIA, Bangalore
Posts: 2,049
Thanks: 16
Thanked 106 Times in 102 Posts
Quote:
Originally Posted by prashant43 View Post
Try
mv sample.F1.Test sample.csv
mv test.F1.Test test.csv
dear prashant,
this code will move the original file but he want to rename it not to move i guess...
    #4  
Old 08-19-2008
Franklin52's Avatar
Franklin52 Franklin52 is offline Forum Staff  
Moderator
 
Join Date: Feb 2007
Last Activity: 23 September 2014, 8:54 AM EDT
Location: The Netherlands
Posts: 7,716
Thanks: 123
Thanked 537 Times in 507 Posts
This gives the commands to remove those files:


Code:
ls *.F1.test | sed 's/\(.*\)\.F1\.Test/mv & \1.csv/'

If the output is correct you can pipe the output to sh.


Regards
Sponsored Links
    #5  
Old 08-19-2008
prashant43's Avatar
prashant43 prashant43 is offline
Registered User
 
Join Date: Jan 2008
Last Activity: 25 August 2011, 6:36 PM EDT
Location: Phoenix
Posts: 32
Thanks: 1
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by vidyadhar85 View Post
dear prashant,
this code will move the original file but he want to rename it not to move i guess...
Dear vidydhar,

thanks for reminding....

If he want to keep original file, he can use
cp sample.F1.Test sample.csv

Regards
Prashant
Sponsored Links
    #6  
Old 08-19-2008
vidyadhar85's Avatar
vidyadhar85 vidyadhar85 is offline Forum Advisor  
The Tutor
 
Join Date: Jun 2008
Last Activity: 9 April 2014, 1:31 AM EDT
Location: INDIA, Bangalore
Posts: 2,049
Thanks: 16
Thanked 106 Times in 102 Posts
Quote:
Originally Posted by prashant43 View Post
Dear vidydhar,

thanks for reminding....

If he want to keep original file, he can use
cp sample.F1.Test sample.csv

Regards
Prashant
but what if he has lots of file ending with F1.test then cp will take a lot of time..
i mean he has to type every time..
Sponsored Links
    #7  
Old 08-19-2008
prashant43's Avatar
prashant43 prashant43 is offline
Registered User
 
Join Date: Jan 2008
Last Activity: 25 August 2011, 6:36 PM EDT
Location: Phoenix
Posts: 32
Thanks: 1
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by vidyadhar85 View Post
but what if he has lots of file ending with F1.test then cp will take a lot of time..
i mean he has to type every time..
If he has lot of files, then he can go for a script,...i guess.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Renaming serial ports in unix superliminal OS X (Apple) 0 05-24-2012 11:00 AM
Renaming a file (non unix person) cavleader UNIX for Dummies Questions & Answers 3 07-08-2010 07:06 AM
File renaming from list of names contained in another file netfreighter Shell Programming and Scripting 7 06-29-2010 05:38 AM
Utility or script for renaming files on UNIX web server everettr Shell Programming and Scripting 2 11-10-2008 05:31 AM
Utility or script for renaming files on UNIX web server everettr UNIX for Advanced & Expert Users 1 10-29-2001 10:16 AM



All times are GMT -4. The time now is 10:24 PM.