Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

How to rename all the files in a folder having specific
extension?
Example: I have some files with extension (.txt) in a folder
name 'Test'. I have to rename all the .txt files in a test
and its subdirectories to .my extension.

Answer Posted / geichel

#!/bin/bash

for x in $(find $1 -name '*.txt' -type f )
do
OUT=$(echo $x | sed -e "s/\.txt$/.my/")
mv $x $OUT
done


exit 0;

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

shell script for reverse the string

1408


Explain about "s" permission bit in a file?

1067


How to find all the files modified in less than 3 days and save the record in a text file?

1066


What are the default permissions of a file when it is created?

1024


What does $@ mean in shell?

1048


What is the difference between break and continue commands?

1108


What is shell and shell script?

1124


What is the syntax of while loop in shell scripting?

1052


What happens when you type ls?

1006


What is the difference between scripting and coding?

1048


Why are shell scripts used?

1087


What are the advantages of using shell scripts?

1073


What language is used in terminal?

993


What are the advantages of shell scripting?

1052


What is shell company all about?

990