Topic "Automating Download from SFTP remote site"

Author Message
falcrawl
[View user's profile]

Joined: 2015-10-07
Posts: 4
All
New to this but achieving some measure of success.
I am connecting to a sFTP site to download a bunch of files everyday to a new folder created everyday by the date stamp. (Done this with a batch file and schedule it to run everyday)
My script is as follows
option batch abort
option confirm off
open sftp://user:password@site.com -hostkey="ssh-rsa 1024 34:2b:a4:06:c7:40:ea:6c:1e:ae:b7:c2:82:34:db:ef"
get -delete -resume -filemask="/Outbox/*.pdf" "Z:\sub1\sub2\MMDDYYYY\
exit

Question.
How can I get the script to verify the correct folder and download the files to that folder for that day. The next day a new folder is created and the files for that day will be downloaded to the current folder

Thanks
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
Not sure what you mean by "verify the correct folder".

But to download files to the folder named after the current day use:

get -delete -resume -filemask="/Outbox/*.pdf" "Z:\sub1\sub2\%TIMESTAMP#mmddyyyy%\

See http://winscp.net/eng/docs/scripting#timestamp
falcrawl
[View user's profile]

Joined: 2015-10-07
Posts: 4
prikryl wrote:
Not sure what you mean by "verify the correct folder".

But to download files to the folder named after the current day use:

get -delete -resume -filemask="/Outbox/*.pdf" "Z:\sub1\sub2\%TIMESTAMP#mmddyyyy%\

See http://winscp.net/eng/docs/scripting#timestamp



Thanks but this did not work.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
falcrawl wrote:
Thanks but this did not work.

Well, would your mind giving us more details? Describing what "does not work"? A log file? Anything?

To generate log file, use /log=path_to_log_file command-line argument. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.
Advertisements

You can post new topics in this forum






Search Site

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!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License