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

Why do we write bin bash in shell scripts?

951


Explain about "s" permission bit in a file?

993


Write a command sequence to find the count of each word?

939


How to get the first line from a file using just the terminal?

1050


What are the advantages of shell scripting?

983


What is shell scripting used for?

932


Write a command sequence to find all the files modified in less than 2 days and print the record count of each.

1436


What is echo in shell?

1043


write a shell script to check the failed jobs?

4349


What is an inode block?

992


What is $1 in shell scripting?

981


What is meant by dos operating system?

988


How does ls command work?

972


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

947


What are the four fundamental components of every file system on linux?

1614