i'm using batch file (named as folder.bat) to add the string "_v0_1" for each foler name under "my folder" (i have about 100 folders under "my folder")
I'm calling my batch (folder.bat) from a onother batch file that contains this rows(for example):
call folder arbiter_logic
call folder arbiter_logic_old
the problem, is that the batch rename folders also when the folder name is longer than the variable name (%1) and i want to avoid it .
I want that the renaming action will execute only if there is exact match between variable %1 and the folder name. Here's my code:
setlocal enabledelayedexpansion
pushd G:\my folder
for /f "tokens=* delims= " %%a in ('dir /b/ad') do (
set x=%%a
set y=!x:%1=%1_v0_1!
ren !x! !y!
)
::==
cd..
currently the unwanted result is:
arbiter_logic_v0_1
arbiter_logic_v0_1_old_v0_1
and the wanted result is that the batch will change the folders name as shown below:
arbiter_logic_v0_1
arbiter_logic_old_v0_1
I'm assuming that there is a need to apply search and replace method within folders names, but i'm not sure how to do so.
vb script will also be a suitable solution if batch file won't do.
Thanks in advance. shay.