Search code examples
windowsbatch-filecommand-linedosbatch-rename

Capitalize first letter of a filename


I have some files in a folder and would like to uppercase the first letter of all the filenames with a certain extension using a batch script in windows.

example cap only *.m

before:

  • foo.m
  • bar.m
  • picture.jpg

after:

  • Foo.m
  • Bar.m
  • picture.jpg

Solution

  • for %%a in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do (
     ren %%a*.m %%a* >nul 2>&1
    )
    

    Check also this -> https://superuser.com/questions/475874/how-does-the-windows-rename-command-interpret-wildcards