Batch File reading text file issue

Advertisement

allbees
Joined:
Posts:
3
Location:
US

Batch File reading text file issue

for /f "usebackq tokens=*" %%x in (ptest.csv) do ( 
echo Starting WinSCP
winscp.com /log=C:\Logs\winscp.log /ini=nul /command ^
    "open sftp://xxx:xxx@ftp.somewhere.com/ -hostkey=""ecdsa-sha2-nistp256 256 blah blah=""" ^
    "lcd ""C:\Images""" ^
    "cd ""/BBIMAGES/LINKS_SPRIDENID""" ^
    "get %%x.JPG" ^
    "exit"
echo WinSCP finished
)

Above is the batch file I am using to open a text file and read each line into a variable. I am then taking the variable adding .jpg to the name and pulling it down form the server. This works, but I am logging in for each new line in the text file. Is there a way I can put the credential in once and the loop through the file until complete?

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,518
Location:
Prague, Czechia

Re: Batch File reading text file issue

Generate WinSCP script in your loop (append new get command in each iteration), and execute WinSCP only once at the end.

Reply with quote

Advertisement

You can post new topics in this forum