Renaming Files In Linux
In a previous post, I wrote about converting strings from camelCase to undescore delimited format.
In this post, we’ll do the same but for file names. We’ll use the command line program “rename” for this purpose.
Here we go:
1. Convert all file names in current directory which are of the form “myFileName” or “MyFileName” into the form of “my_file_name”:
1 | rename 's/(.)([A-Z])/$1_\l$2/g' * && rename 's/([A-Z])/\l$1/g' * |
2. Convert all file names in current directory which are of the form “my_file_name” into the form “myFileName”:
1 | rename 's/([a-z])_([a-z])/$1\u$2/g' * |
3. Convert all file names in current directory which are of the form “my_file_name” into the form “MyFileName”:
1 | rename 's/([a-z])_([a-z])/$1\u$2/g' * && rename 's/^([a-z])/\u$1/g' * |
Enjoy
Related posts:

[...] Renaming Files In Linux [...]