I have 100 folders under a directory with naming in a pattern. Ex: DeDeP001M1TSub, DeDeP002M1TSub,...,DeDeP100M1TSub.
I am looking for a command line option to rename all the folders. I just want to change M1 to M2 as in DeDeP001M1TSub becomes DeDeP001M2TSub. I know of 3rd party applications that can do this, but am looking for a command line option to use in a bat file along with bunch of other stuff. Please help(Fairly new to the area)!!
So far have tried ren,mv but to no effect(not very familiar with dos scripting).
This should do it:
@echo off
setlocal enabledelayedexpansion
for /d %%a in (*) do (
set "p=%%a"
set "fp=!p:~0,8!" & set "tp=!p:~10!"
echo ren %%a !fp!M2!tp!
)
Remove the echo once you verify the output is what you want to do the actual rename.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With