WinSCP copy from downloads to local folder

Advertisement

rscarb99
Guest

WinSCP copy from downloads to local folder

I have what seems like a simple question but I am doing something wrong.
I have WinSCP configured to log into a Sharefile website, pull down a daily txt file. Once downloaded I want it automatically moved to a different folder.
I thought this would be simple, I am doing something wrong.
Any input is welcomed.

Code:
@echo off
"C:\Program Files (x86)\WinSCP\WinSCP.com" /log="C:\winscp.log" /command ^
    "open sftp://deltalifeins/sa_automation@email.com:XXXXXXX@emailaddress.sharefileftp.com/ ^
    "get /VendorUpload *.txt D:\Data" ^
    "exit"

Reply with quote

Advertisement

AI helper
Guest

Re: WinSCP copy from downloads to local folder

Hello rscarb99,

You can download directly into the destination folder; a second local move is unnecessary. There are two visible syntax problems in the sample: the open command's closing quote is missing, and /VendorUpload and *.txt need to be one remote file mask.

The WinSCP command is:
get "/VendorUpload/*.txt" "D:\Data\"
The final backslash identifies D:\Data\ as the destination directory. Create that directory first, or substitute your actual destination.

For the connection line, use the already-working GUI session: Tabs > Generate Session URL/Code > Script, then choose Script file. Keep its generated open line and verified host-key fingerprint. This avoids manually encoding the slash and @ characters in your username. Keep the generated credentials private.

Save this as download.txt, replacing the commented placeholder with that generated open line:
option batch abort
option confirm on
option failonnomatch on
# Paste the complete generated open command here.
get "/VendorUpload/*.txt" "D:\Data\"
exit
Then, from the directory containing download.txt:
"C:\Program Files (x86)\WinSCP\WinSCP.com" /ini=nul /log="winscp.log" /script="download.txt"
This copies matching remote text files and leaves the remote originals in place. confirm on prevents silent overwrites; inspect the log for skipped or failed transfers if a same-name local file exists. failonnomatch makes a missing match an error. For one particular daily file, replace *.txt with its exact filename.

Official references:
https://winscp.net/eng/docs/scriptcommand_get
https://winscp.net/eng/docs/scriptcommand_option
https://winscp.net/eng/docs/ui_generateurl

AI-generated reply, checked against the documentation; not run in Windows or against your server. Not affiliated with WinSCP.

Reply with quote

Advertisement

You can post new topics in this forum