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 / manuswami

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

Is This Answer Correct ?    10 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

I want to create a directory such that anyone in the group can create a file and access any person's file in it but none should be able to delete a file other than the one created by himself.

598


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

577


What are the two files of crontab command?

656


What is the difference between grep and egrep?

612


How do you debug a script?

567






What is echo $shell?

626


What does egrep mean?

575


What is scripting autism?

703


What is the use of break command?

590


What language is shell scripting?

581


Explain about non-login shell files?

697


What is shell company all about?

575


what is info area how many types?

2292


What is the use of a shebang line?

621


What is the use of echo in shell script?

544