I relatively new to Batch Scripts
and i am trying to create a windows batch file that renames a static array values in one group against an static array values in another - moving to another folder. Something like this:
setlocal EnableDelayedExpansion
set currentDate=%date:~-4,4%%date:~-10,2%%date:~-7,2%
set fromPath=C:\
set toPath=C:\Temp\
set fileList=(temp1.txt temp2.txt temp3.txt)
set toList=(name1 name2 name3)
I'm looking at this style of array as its looks easier for the user i'm giving it to to add to the list.
Alone (without the toList) the fileList works fine:
for %%i in %fileList% do (
IF EXIST %FromPath%%%i
ren %FromPath%%%i %%~ni_%currentDate%%%~xi &
move %FromPath%%%~ni_%currentDate%%%~xi %toPath%
)
But obviously this does not do the renaming from toList
in the same order as the list in toList
.
I tried code with a counter with an index like this (tried other variants of below aswell) with no luck:
for /L %%i IN (0,1,10) DO (
IF EXIST %FromPath%%fileList[%%i]%
ren %FromPath%%%i %%~ni_%currentDate%%%~xi &
move %FromPath%%%~ni_%currentDate%%%~xi %toPath%
)
Is something like this possible? If not, I'm open to any other suggestion to the above.
Thanks in advance!