I am not really familiar with batch scripts so I would really appreciate some help here! I have been trying to copy and rename a bunch of files using two txt files. The chart_list.txt file will have the origin names.
chart_list.txt
Chart_A1_86_88.png
Chart_A2_86_88.png
Chart_B1_86_88.png
Chart_B2_86_88.png
The newchart_list.txt file will have the destination names.
newchart_list.txt
Chart_A1.png
Chart_A2.png
Chart_B1.png
Chart_B2.png
Looking at the following post (in windows batch file, how to loop 2 sets simultaneously and Copy a list (txt) of files), I came up with the following :
setlocal enableextensions enabledelayedexpansion
@echo off
set src_folder=C:\Source
set dst_folder=C:\Destination
set flag=0
for /f "tokens=*" %%i in (chart_list.txt) DO (
set /A flag+=1
echo !flag!
set flag2=0
for /f "tokens=*" %%j in (newchart_list.txt) DO (
set /A flag2+=1
echo !flag2!
if !flag! == !flag2! (
copy "%src_folder%\%%i" "%dst_folder%\%%j" /Y
)
)
)
@pause
The purpose is really to have the name in the first line of chart_list and newchart_list to match. However, when I execute the command nothing happens. the cmd window shows
1
0
0
0
0
2
0
0
0
0
3
0
0
0
0
4
0
0
0
0
(I added the echo
command to see if flag and flag2 were actually changing but it doesn't seem to be the case for flag2 which remains set to 0).
Thanks a lot in advance for your help!