Rename all files in the folder to uppercase with the package

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

for /f "Tokens=*" %f in ('dir /l/b/a-d') do (rename "%f" "%f")
+4
source share
2 answers
@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
+8
source

This will also add the extension to uppercase ... What was the problem for me ... So, how I "saved" the extension as a lowercase ...

accepted
@echo off
setlocal enableDelayedExpansion

pushd C:\WIS\Connect_Phoenix\CONNECT_FILES_FOR_UPLOAD\17Q4_PDFs

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
)

for /r "C:\WIS\Connect_Phoenix\CONNECT_FILES_FOR_UPLOAD\17Q4_PDFs\" %%G in (*.PDF) do ren "%%~G" *.pdf

endlocal
0
source

All Articles