Tom, fiddling around with a previous script I posted, here is one processing all files and subdirectories:
recurename.cmd directory
@echo off
setlocal ENABLEDELAYEDEXPANSION
set Replaces="V=Y" "W=Z" "m=A"
set StartDir=%~dp1
call :RenameDirs "%StartDir:~0,-1%"
exit /b 0
:RenameDirs
call :RenameFiles "%~1"
for /f "delims=" %%d in ('dir /ad /b "%~1"2^>nul') do call :RenameDirs "%~1\%%~d"
if "%~1"=="%StartDir:~0,-1%" exit /b 0
set _pos=0
set _dir=%~f1
set _dir_orig=!_dir!
:finddirName
set /a _pos-=1
call set _dir_pos=!!!_dir:~%_pos%,1!!!
if not "%_dir_pos%"=="\" goto finddirName
call set _origines=!!!_dir:~0,%_pos%!!!
set /a _pos+=1
call set _dir=!!!_dir:~%_pos%!!!
for %%r in (%Replaces%) do call set _dir=!!!_dir:%%~r!!!
if /i not "!_dir!"=="!_dir_orig!" echo move "%~1" "%_origines%\!_dir!"
exit /b 0
:RenameFiles
for /f "delims=" %%f in ('dir /a-d /b "%~1"2^>nul') do (
set _file=%%~nf
set _file_orig=!_file!
for %%r in (%Replaces%) do call set _file=!!!_file:%%~r!!!
if /i not "!_file!"=="!_file_orig!" echo ren "%~1\%%f" "%~1\!_file!%%~xf"
)
exit /b 0
___Notes____
This is a non-destructive script, remove the echo from the correct commands in order to rename any file/directory. (echo move and echo ren)
Set Replaces=: Set this variable to whatever pairs you need changed.
set Startdir=: I wanted to secure, somehow, the argument and taking only the path from it. If a files is given as a parameter, the whole container directory and subdirs will be processed.
if "%~1"=="%StartDir:~0,-1%" exit /b 0: This line was placed to stop the argument directory itself from being processed. If you wish so, remove this line.
If the script is called with, say, *c:\temp\*, removing this line would change the name to *c:\teAp\* in the end.