Linux: Rename extension of multiple file in a folder

I sometimes need to change extension of multiple files in a folder. So I wrote a bash script to do this easily. And I am sharing it from here. It’s simple to use it. For example; you have a folder named folder1 and it has files with the extension ‘.abc‘ in it. And you want to change ‘.abc‘ extension with ‘.txt‘. The only thing you must do is run the commandline bottom;

bash rename_extension.sh abc txt /dir1/dir2/folder1

You can download script from here.

[pastacode lang=”bash” manual=”%23!%2Fbin%2Fbash%0A%0A%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%0A%23%20%20C*%20%20%20%20%20%20%20%20%20%20rename_extension.sh%20%20%20%20%20%20%20%20%20%20%20C*%20%20%23%0A%23%20%20C*%20%20%20%20%20%20%20written%20by%20Nuh%20Azginoglu%20%20%20%20%20%20%20%20%20C*%20%20%23%0A%23%20%20C*%20%20%20%20%20%20%20%20%20%20%20February%2009%2C%202016%20%20%20%20%20%20%20%20%20%20%20%20C*%20%20%23%0A%23%20%20C*%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20C*%20%20%23%0A%23%20%20C*%20%20renames%20files%20with%20new%20extension.%20%20%20%20%20C*%20%20%23%0A%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%0A%0Aecho%20%22usage%3A%20bash%20rename_extension.sh%20old_extension%20new_extension%20directory%22%0A%0A%0Aold_extension%3D%241%0Anew_extension%3D%242%0Adirectory%3D%243%0A%0Afor%20file%20in%20%24directory*.%24old_extension%3B%20do%0A%20%20%20%20mv%20%22%24file%22%20%22%24directory%60basename%20%24file%20.%24old_extension%60.%24new_extension%22%0Adone” message=”” highlight=”” provider=”manual”/]

Yazının Türkçe versiyonuna buradan erişebilirsiniz.

 

Bugün 1, bugüne kadar toplam 42 kez ziyaret edildi.

Bir yanıt yazın

E-posta adresiniz yayınlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir