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 is info area how many types?

2299


What are the advantages of shell script?

529


What exactly is a shell?

608


What is meant by dos operating system?

586


What is the use of "$?" Sign in shell script?

626






What are the different types of variables used in shell script?

558


What are the advantages of using shell scripts?

593


What is scripting used for?

571


Is shell a scripting language?

578


Explain about return code?

638


What is shell scripting?

599


madhar chod unix ke 10 commands dhang se likh nahi sakta hai

2980


How to print pid of the current shell?

606


How to print all array elements and their respective indexes?

515


What is a shell made of?

565