HowTo: Unix / Linux Rename File Extension From .OLD to .NEW

by on March 12, 2011 · 0 comments· LAST UPDATED March 12, 2013

in , ,

How do I rename a file called resume.docz to resume.doc? I would like to rename a .txt file as .doc file. How do I rename a file called foo.txt to foo.doc under Linux / Unix / Apple OS X / *BSD operating systems using the command prompt?

You need to use mv command. The syntax is as follows:

 
mv old-file-name new-file-name
 

To rename a file called resume.docz to resume.doc, run:

 
mv resume.docz resume.doc
ls -l resume.doc
 

To rename file extension from .txt to .doc, enter:

 
mv foo.txt foo.doc
ls -l foo.doc
## error ##
ls -l foo.txt
 

To fix the extension of all your .txt files, enter::

 
rename .txt .doc *.txt
 

The above command will rename all *.txt files to *.doc i.e. fix the extension of your txt files.



If you would like to be kept up to date with our posts, you can follow us on Twitter, Facebook, Google+, or even by subscribing to our RSS Feed.


{ 0 comments… add one now }

Leave a Comment

You can use these HTML tags and attributes for your code and commands: <strong> <em> <ol> <li> <u> <ul> <kbd> <blockquote> <pre> <a href="" title="">

Tagged as: , ,

Previous Faq:

Next Faq: