Saturday, July 05, 2008

How to change all file extensions in a folder,

This post also applied to other actions such as copying, removing to manage and organize your Linux file system more effectively.

To make sure that you do not destroy your real files, I use the folder /tmp resided the home directory to carried out this tutorial. You can create a new one if you like.

mkdir /tmp
cd tmp

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

for x in {1..100}; do touch "file$"; done

And 200 new files as Gif images

for x in {1..200}; do touch "myimage$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" "${}.bak"; done 

credits : NFT team

No comments:

Post a Comment