rename filenames 'Extensions' EVEN in SubFolders

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
jamesfui
Posts: 50
Joined: 27 Mar 2010 23:00

rename filenames 'Extensions' EVEN in SubFolders

#1 Post by jamesfui » 09 Apr 2010 18:12

hi everyone!
what is the bat scripts for Renaming filenames 'Extensions' EVEN in SubFolders..
in reference to its filenames... like for example,

c:\old files\pictures\album01\filenames01.bMp
c:\old files\pictures\album01\filenames02.BmP
TO
c:\old files\pictures\album01\filenames01.BMP
c:\old files\pictures\album01\filenames02.bmp

the main objective is to rename all the extension to uppercase in respect with its filename01 & filename02 to extension in lowercases!!
But have to be able to Run through even in Sub-folders too..

like the scripts destination can just set to c:\old files\
instead of the long full path c:\old files\pictures\album01\

thanks!! :mrgreen:

!k
Expert
Posts: 378
Joined: 17 Oct 2009 08:30
Location: Russia

Re: rename filenames 'Extensions' EVEN in SubFolders

#2 Post by !k » 10 Apr 2010 01:35

Code: Select all

@echo off
for /f "delims=" %%f in ('dir /s /b /a-d "c:\old files"') do (
if /i "%%~xf"==".bmp" ren "%%~dpnf.bmp" "%%~nf.BMP"
)

avery_larry
Expert
Posts: 391
Joined: 19 Mar 2009 08:47
Location: Iowa

Re: rename filenames 'Extensions' EVEN in SubFolders

#3 Post by avery_larry » 12 Apr 2010 09:38

*untested* probably a bit more efficient:

Code: Select all

for /f "delims=" %%f in ('dir /s /b /a-d "c:\old files\*.bmp"') do ren "%%f" "%%~nf.BMP"

Post Reply