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
What is echo in shell?
How to get the last line from a file using just the terminal?
What is a file basename?
What is in a script?
Is shell scripting useful?
Is cmd a shell?
What does echo mean in scripting?
how to print the 2-d, 3-d arrays in unix shell script programs please answer thi questio to my mail venusaikumar@gmail.com
What is difference between bash and shell?
What is the syntax of "nested if statement" in shell scripting?
Why is the use of shell script?
How do you find out What is your shell?
one folder contains lot of students name but I want to fetch hello with every student name individually using shell script
What is the difference between grep and egrep?
How to calculate the number of passed arguments?