Topic "DATE variable for script to tranfer a folder from W do U"

Author Message
[View user's profile]

Joined: 2012-05-29
Posts: 1
Hi all,
I know this must be a stupid question, but I'm getting mad for this...
I need to daily tranfer a folder from a Windows Server to a Red Hat one.
This folder on the windows server has the naming convention of "Stats_dd-mm-yyyy".
I'm trying to create a script for automate a daily sftp between this two folder, but I'm not able to pass the "date" variable.
Here is the script i'm trying:

#Automatically abort script on errors
option batch abort
# Disable overwrite confirmations that conflict with the previous
option confirm off
set Stats_dd-mm-yyyy=Stats_%date:~4,2%-%date:~7,2%-%date:~10,4%
# Connect
open s -hostkey="ssh-rsa 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
# Force binary mode transfer
option transfer binary
#Put file to the remote directory /tmp
put C:\Scripts\output\%Stats_dd-mm-yyyy% /tmp/test_Stats/
#Log activities
# Disconnect
# Exit WinSCP

Every time I run this I get error becouse of the "set" command, it's not recognized...
Where am I wrong?????
Thank you
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
There's no "set" command in WinSCP.

You probably wanted to do somethink like:

set Stats_dd-mm-yyyy=Stats_%date:~4,2%-%date:~7,2%-%date:~10,4% /script=script.txt

option batch abort
open s -hostkey="ssh-rsa 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
put C:\Scripts\output\%Stats_dd-mm-yyyy% /tmp/test_Stats/
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