Rename all files in folder to uppercase with batch

rikket picture rikket · Aug 8, 2014 · Viewed 16.3k times · Source

Is there a way to rename all files in a specific folder to uppercase with batch file?
I found this code. But it renames files to lowercase. How to modify it to rename to uppercase instead?

for /f "Tokens=*" %f in ('dir /l/b/a-d') do (rename "%f" "%f")

Answer

npocmaka picture npocmaka · Aug 8, 2014
@echo off
setlocal enableDelayedExpansion

pushd c:\some_dir

for %%f in (*) do (
   set "filename=%%~f"

   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 (
      set "filename=!filename:%%A=%%A!"
   )
    ren "%%f" "!filename!" >nul 2>&1
)
endlocal