Topic "SFTP Get error"

Author Message


I have this below script which gets the files from multiple sftp servers setup in csv file
each row of the csv file - source file/target file/source folder/target folder/sftp server details.

I loop through each row and get the file, this works, but fails when there is no file to get -"can't get attributes for file"

The problem to me is -
for each row I have one session or open command execution - This I didn't like. There are multiple rows in the csv file with same server details. I want to look through each row and see if its a new sftp server, if it is, create a new session and get the file.

To accomplish this, I tried using a flags and check if the previous row host and current is same, if same I wanted to use the same session..
Here is the catch -
after opening the session, it doesn't allow any windows batch commands in between winscp commands

Need your help to find a solution to this generic solution.

FOR /f "tokens=1-12* delims=," %%A IN (D:\GENSRVNT\SFTP_TOOL_WK\sftpconfig_Get.csv) DO (

"C:\Program Files (x86)\WinSCP\" /log="D:\GENSRVNT\SFTP_TOOL_WK\TestSFTPLog.txt" /command >> "D:\GENSRVNT\SFTP_TOOL_WK\TestSFTPLog1.txt" ^
"open sftp://"%%~F"@"%%~H"/ -hostkey=""%%~I"" -privatekey=""%%~J"" -passphrase=""%%~K"" " ^
"get -append -delete -resumesupport=off %%~A/%%~B %%~D\%%~C" ^

if %ERRORLEVEL% neq 0 (
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26462
Location: Prague, Czechia
That's too complicated for a batch file.

Use PowerShell (or other good scripting language) and WinSCP .NET assembly.

You can post new topics in this forum


What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!


About donations

$9   $19   $49   $99

About donations


WinSCP Privacy Policy

WinSCP License