December 5th, 2002, 05:58 AM
Changing file extension
I wanna move files with "*.doc" extn to "*.txt ".
Is there any command in unix to do that? or we have to go for shell script?
December 5th, 2002, 08:07 AM
rename s/\.txt/.doc/ *.txt
Or if you want to use a more sophisticated regex to avoid documents like this-has-a-.txt-that-is-not-the-extension.txt being changed into this-has-a-.doc-that-is-not-the-extension.txt
then that's fine as well. But that's an okay regex for 95% of the cases.
Oh, also, this isn't a "standard Unix(TM) command, but it does come with most Perl installations that I know of and Perl is on most Unix machines that I know of.
December 5th, 2002, 08:20 AM
Hey - Thanks for reply...
Can you pls make it on Shell script?
In my system perl is installed ...but i dunno how to execute this cmd...when i type this command it is thrwoing syntax error
December 5th, 2002, 01:40 PM
for i in *.txt; do mv "$i" `basename $i`.doc; done
December 6th, 2002, 08:20 AM
It works ..thanks you guys ....