Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

Re: How to create directory and move to this new directory

The simplest solution is just repeat %TIMESTAMP#yyyy-mm-dd-hh%. I understand that there's a small risk that "hour" changes between the two lines.

If you want to be 100% sure, you can query the timestamp before starting the actual script (based on Formatting Timestamp in Batch File):
for /F "tokens=* USEBACKQ" %%F in (
    `winscp.com /command "echo %%TIMESTAMP#yyyy-mm-dd-hh%%" "exit"`
) do set THE_TIMESTAMP=%%F
 
winscp.com /script=script.txt

And then in the script.txt WinSCP script, you can use %THE_TIMESTAMP% environment variable repeatedly.
Alternatively, instead of environment variable, you can use script argument.
a74399

How to create directory and move to this new directory

I want to schedule some commands on a daily frequency and create different directories every day (with the filename being the date and time), and upload some files afterward.
So I basically need something like:
mkdir %TIMESTAMP#yyyy-mm-dd-hh%
cd "last argument"

Is there a way to do this?
Thanks in advance.