Posted: 2016-11-18 19:30
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\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).
# Connect to SFTP server.
open sftp://user:firstname.lastname@example.org_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.
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?
Posted: 2016-11-18 23:03
Please nevermind, I've found the correct way to do!
Location: Prague, Czechia
You can post new topics in this forum
And it's free!