7

How can one change the first letter of a filename to uppercase using a command line?
IS there any command line to do so?

15

Using the rename command:

rename -n 's/./\U$&/' *
  • -n only shows what changes will be made. After you verify the changes, run without -n to actually rename the files.
  • s/./\U$&/: substitutes the first character (.) with the uppercase (\U) of whatever was matched ($&).

Example:

$ ls
bar  foo
$ rename -n 's/./\U$&/' *
rename(bar, Bar)
rename(foo, Foo)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.