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 / prav gir

#!/bin/sh
for filename in *$1*
do
echo "$filename"
mv -f "$filename" `echo $filename|sed "s/$1/$2/"`
done
run script like
$>scrpt1 .txt .my

Is This Answer Correct ?    3 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does sh mean?

1004


wats the deinitions for shell utility and filter?

2251


c program the catches the ctrl-c(SIGINT) Signal for the first time and prints a output rather and exit on pressing Ctrl-C again

6320


How do you know which shell I am using?

984


What is the use of a shebang line?

1112


Is shell scripting a language?

978


What does $0 mean in shell script?

937


What does echo $0 do?

915


How do you debug a script?

1000


How do I set bash as default shell mac?

944


How do you find out What is your shell?

1007


Write down the syntax of "for " loop

1035


How do I start a shell script?

1124


How do you create a shortcut in linux?

1117


How will you print the login names of all users on a system?

916