I've reviewed many posts herein regarding this problem, but I believe I am doing it correctly.
I have a large Windows batch file that is used to download files from a remote server one-by-one.
The commands used follow:
"C:\Program Files (x86)\winscp"\winscp.exe /log=%logfile% /command "option batch abort" ^
"option confirm off" ^
"open sftp://%email@example.com/ -hostkey=""ssh-rsa 1024 23:98:ad:a0:0f:d6:d0:bc:cb:bb:2b:f7:37:91:37:4c""" ^
"get -delete ""%remoteFolder%/%directory%/%file%"" %localRoot%\%directory%\" ^
It uses several shell variables.
"xyz" is the user name and password
"remoteFolder" and "directory" is the path on the remote server
"localRoot" is the local path
"file" is the file name, which may or may not contain spaces. Nothing happens when the name contains a space.
I have looked at the log file. It appears that winscp never gets the full file name. For example, if the remote file name is "A B.txt", winscp only sees "A". At least, that's what it logs.