Post a reply

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)


Topic review


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 (
    ` /command "echo %%TIMESTAMP#yyyy-mm-dd-hh%%" "exit"`
) do set THE_TIMESTAMP=%%F /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.

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.