Hegwin.Me

In silence I feel full; With speech I sense emptiness.

Batch update file extensions in Linux

Linux批量修改文件扩展名

A colleague of mine organized several thousand pdf files and needed to perform some batch operations. After uploading to the server, only to find that the extensions inside are uppercase .PDF, some are lowercase .pdf. This brings some trouble, because we have a program on the server that only recognizes the lowercase extensions; The colleague is working with Windows OS, which by default does not show the extensions so it was completely missed before uploading.

The good thing is that the files are in the same directory, the basic use of rename this command will be able to handle it.

In CentOS:

rename .PDF .pdf *.PDF

Well, our test server is CentOS and our production server is Ubuntu, and it seems that the parameters of the rename command are not quite the same.

In Ubuntu:

rename 's/\.PDF/\.pdf/' *
< Back