Windows batch: send multiple files based on a txt file

Hello experts,
I have the following code which allows me to send single file to a website.
I would like to modify as following:
1-Add a for each loop and place the various names in another list.txt file. Script should loop the various names reported in the the list.txt and send files.
If you have questions, please contact me.
Thank you in advance for your help.

@echo off

rem Set curl path.
set CURL="curl/curl"

cd "%cd%"

rem Set site url.
set SITE_URL=

rem Set login.
set LOGIN=

rem Set password.
set PASSWORD=

rem Set service number.
Set SERVICE_NUMBER =

rem Set action url.
set ACTION_URL=%SITE_URL%/sendFile/%SERVICE_NUMBER%

rem Set input file path and name.
set PARAM_PROXY=

set FILE="file=@toto.csv"

rem Import the file.
curl -v -k %ACTION_URL% -u %LOGIN%:%PASSWORD% -F %FILE%

pause

Open in new window

LVL 1
LD16Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bill PrewIT / Software Engineering ConsultantCommented:
Here's a starting place for you.  Basically anything that does not depend on the file name can stay outside the FOR loop, but I wasn't sure of all of those since you don't have values provided in your example, which I understand you did due to sensitive values in some cases.  Adjust as needed.

@echo off
setlocal EnableDelayedExpansion

set FileList=c:\temp\filelist.txt

rem Set curl path.
set CURL="curl/curl"

cd "%cd%"

rem Set site url.
set SITE_URL=

rem Set login.
set LOGIN=

rem Set password.
set PASSWORD=

rem Set service number.
Set SERVICE_NUMBER=

rem Set action url.
set ACTION_URL=%SITE_URL%/sendFile/%SERVICE_NUMBER%

rem Set input file path and name.
set PARAM_PROXY=

for /F "tokens=*" %%F in ('type "%FileList%") do (
    rem Import the file.
    curl -v -k %ACTION_URL% -u %LOGIN%:%PASSWORD% -F "file=@%%~F"
)

pause

Open in new window


»bp

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
LD16Author Commented:
Thank you Bill.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.