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 / venugopal adep

for file in `ls *.txt`; do new_file=`echo $file | sed
's/txt/my/g'`; mv $file $new_file; done

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is shell and shell script?

558


write a shell script to check the failed jobs?

3958


How does shell scripting work?

617


What is bash eval?

549


Is shell scripting easy to learn?

571






What does echo mean in scripting?

592


Why is it called a shell?

507


Which scripting language is best for automation?

536


I want to connect to a remote server and execute some commands, how can I achieve this?

577


Why is a script important?

565


How do I stop script errors?

576


What are the different communication commands available in the shell?

519


What is echo $shell?

626


What does echo $0 do?

586


one folder contains lot of students name but I want to fetch hello with every student name individually using shell script

516