Creating a folder on a FTP using the current date



Creating a folder on a FTP using the current date


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?



Reply with quote



You can post new topics in this forum