How to change all file extensions in a folder

To make sure that you do not destroy your real files make a copy to temporary folder.

# mkdir /tmp
# cd tmp

Now, I’m in the folder /tmp. Currently, this is a empty working directory. We  make 500 new files in the extension .dot as the following:

# for x in {1..500};

do

touch “file$x.dot”;

done

And 200 new files as Gif images

# for x in {1..200};

do

touch “testimage$x.gif”;

done

Now, how can I rename all files .dot to .bak in the folder /tmp? The following command can solve this problem.

# for x in *.dot;

do

mv “$x” “${x%.dot}.bak”;

done

Other example :

# for x in *.mov;

do

mv “$x” “${x%.mov}.flv”;

done

This entry was posted in Windows. Bookmark the permalink.

Leave a Reply

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

*


6 − = zero

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>