Topic "Creating a folder on a FTP using the current date"

Author Message
Gigabyte

Guest


Hi,

I'm using a combination of batch file and WinSCP script to automate uploading files on a FTP on a daily basis.

To keep the FTP structure clean, I must create a new folder that is named according to the current date.

This is what I use in my batch file:

Quote:
For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%a-%%b)
For /f "tokens=1-2 delims=/:" %%a in ('time /t') do (set mytime=%%a-%%b)
echo %mydate% %mytime% (PST) - Starting WinSCP. >> RESULTS.log

"c:\Program Files (x86)\WinSCP\WinSCP.com" /script=HA_OUT.txt /log=HA_OUT.log /loglevel=0 /parameter="%mydate%"
...


The variable %mydate% correctly resolves to the current date, for example "2016-11-18".

This is the part from my WinSCP script where I connect to the FTP and try to create a folder named with the current date (2016-11-18).

Quote:
# Connect to SFTP server.
open sftp://user:password@sftp.my_site.com/ -hostkey="ssh-dss 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"

# Now connected to the SFTP server, moving to the remote directory and creating a sub-directory named using the current date.
cd DailyDeliveries
mkdir "%1%"


Now what happens is that I get a new directory created, but the name is "%1$" instead of "2016-11-16".

Am I doing something wrong, the wrong way, or is it just not supported? Is there another way to do this?

Thanks!

GB
Guest




Hello again,

Please nevermind, I've found the correct way to do! Smile

GB
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26447
Location: Prague, Czechia
Use the %TIMESTAMP% syntax:
https://winscp.net/eng/docs/scripting#timestamp
Advertisements

You can post new topics in this forum






Search

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