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

Explain how you Automate your application using Shell scripting.

2297


What are the various stages of a linux process it passes through?

1159


What language is bash?

904


What is computer cli?

883


What is wc in shell script?

964


What is the use of "$#" in shell scripting?

1035


Print the 10th line without using tail and head command.

2162


Is scripting and coding the same thing?

966


Can you write a script to portray how set –x works?

985


What is difference between shell and bash scripting?

973


Suppose you execute a command using exec, what will be the status of your current process in the shell?

1053


How do I run a script from command prompt?

1059


How to use arguments in a script?

1083


What is shell variable?

903


What is the difference between grep and egrep?

1115