Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

allbees

That makes sense. Some of the files in .csv file are not in the ftp folder. Does the script stop when it encounters and error for file not found?
martin

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.
allbees

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?