• Uncategorized

About linux : How-to-rename-all-the-files-from-a-directory

Question Detail

So, i have a given directory, and that directory contains other subdirectories, and every subdirectory can contain a file. I have to change all the files names, so that it will end in “.txt” .

Question Answer

**You can do something like this using bash : and go over all your directories with it **

for f in *.their_current_end;
    mv -- "$f" "${f%.their_current_end}.txt"

another solution would be using : rename in Linux

rename [OPTIONS] perlexpr files

where the rename will rename all the files mentioned like the regex supplied in the perlexpr parameter.

example :

rename 's/.html/.php/' \*.html

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.