Se as colunas Client name
tiverem nomes iguais de arquivos na pasta com extensão .txt
, o seguinte lote deverá ser feito.
:: Q:\TEST17-05\DEMO\SU_1212933.cmd
@Echo off
For %%A in (".\folder") Do Set "folder=%%~fA"
( for /f "skip=1 usebackq tokens=1* delims=," %%a in (
".\list.csv"
) do If Exist "%folder%\%%b.txt" Type "%folder%\%%b.txt"
) >".\Report.txt"
Para demonstrar isso é o meu ambiente de teste
> tree . /F
Q:\TEST17-05\DEMO
│ SU_1212933.cmd
│ list.csv
│ Report.txt
│
└───folder
James Bond.txt
Doctor Evil.txt
o conteúdo dos dois arquivos txt em folder
> type folder\*.txt
folder\James Bond.txt
#################################################
## this is file "James Bond.txt" in folder ##
#################################################
folder\Doctor Evil.txt
#################################################
## this is file "Doctor Evil.txt" in folder ##
#################################################
Depois de executar o lote, o arquivo report.txt contém:
> type Report.txt
#################################################
## this is file "James Bond.txt" in folder ##
#################################################
#################################################
## this is file "Doctor Evil.txt" in folder ##
#################################################