Button including batch-command

Hello,

is it possible to make a button which has a batch command "inside"? Pressing the button should execute the following code - without an existing .cmd/.bat-file somewhere:

set year=%date:~6,4% set month=%date:~3,2% set day=%date:~0,2% mkdir "%year%-%month%-%day%"

I know that DO has a command like "CreateFolder {date}" but this is not the problem :wink: I'm interested in the batch thing :smiley:

Yes, just set the function drop-down to MS-DOS in the button editor.

Yes, I've tried this before but nothing happens.

[quote="Mr Speed"]Yes, I've tried this before but nothing happens.
[/quote]

Because your code is wrong. Correct code is:

call set year=%date:~0,4% call set month=%date:~5,2% call set day=%date:~8,2% mkdir "%year%-%month%-%day%"

After all - now Opus creates a button,
but the result looks strange on a German system.
Please have a look :open_mouth:

Add a line with @externalonly to the start of the command. Otherwise you will run Opus's Set command instead of the MS-DOS Set command.

Since %date% changes depending on syetem locale settings, splitting it up like that isn't a great idea, by the way. On my system the command goes badly wrong and creates a mess (or doesn't work at all) because %date% turns into 24/Jul/2008 which is then turned into /200-Ju-24

You could make Opus generate the date for you if you want it in a particular format:

mkdir "{date|yyyy-MM-dd}"

That also works with the internal CreateFolder command, of course.

@Leo
Thanks! Now it works! Fantastic!
That mkdir "{date|yyyy-MM-dd}" is great!

@searcher123
This was true. I haven't seen the "call".
So for German XP-systems the code has to look like that:

call set year=%date:~6,4% call set month=%date:~3,2% call set day=%date:~0,2% mkdir "%year%-%month%-%day%"

CreateFolder "{date|yyyy-MM-dd}" is even better since you'll get error messages etc.

It's faster!

Hello again,

the result of CreateFolder "{date|yyyy-MM-dd}" is
2008-07-25

  1. What do I have to do when I want to add time?
    2008-07-25_12-23 (or so :wink:)

  2. Back to CreateFolder "{date|yyyy-MM-dd}"

a) Is it possible to add a prefix to it?
leo_2008-07-25

b) Or something after the date
2008-07-25_leo

[quote="Mr Speed"]

  1. What do I have to do when I want to add time?
    2008-07-25_12-23 (or so :wink:)[/quote]

CreateFolder "{date|yyyy-MM-dd}_{time|hh-mm-ss}"

[quote="Mr Speed"]
a) Is it possible to add a prefix to it?
leo_2008-07-25[/quote]
CreateFolder "leo_{date|yyyy-MM-dd}"

[quote="Mr Speed"]
b) Or something after the date
2008-07-25_leo[/quote]

CreateFolder "{date|yyyy-MM-dd}_leo"

Thanks again searcher123!

Hello again,

need a Button that creates an empty yyyy-mm-dd text file.
--> 2009-05-02.txt

What I have to do?

[quote="Mr Speed"]need a Button that creates an empty yyyy-mm-dd text file.
--> 2009-05-02.txt[/quote]
One way to do it:

Copy FILE="nul" AS="{date|yyyy-MM-dd}.txt" HERE

Great! Thanks again, Leo! :slight_smile:

Another way:

Filetype NEW=norename:.txt NEWNAME="{date|yyyy-MM-DD}"

Thanks Jon :slight_smile: