Topic "Copying a file from SFTP with date time"

Author Message



I have a file named datafile-2014-06-30.txt in an SFTP location and I am trying to copy to a different location. (Date is today's date)
I have written the following script, but it fails with an error: Can't get attributes of the file '%file%'

option batch on
option confirm off
set file=datafile-%date:~7,2%-%date:~10,4%-%date:~4,2%.txt
open s
get %file%

Any help on this would be great. Thanks.
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24735
Location: Prague, Czechia
You seem to be mixing WinSCP and Windows commands.

See this (otherwise unrelated) article to learn how to work with environment variables in WinSCP script:
Martin Prikryl

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!


About donations

$9   $19   $49   $99

About donations


WinSCP Privacy Policy

WinSCP License