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

Author Message



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:

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\" /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).

# Connect to SFTP server.
open s -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?



Hello again,

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

[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26138
Location: Prague, Czechia
Use the %TIMESTAMP% syntax:

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