Create new folder with current time under the results folder

Hi,
In robot framework:
I want that the file results will be saved under a new folder that has the current date and time
like this: Results/current date time folder/ file results

how can I do it?

Hi Gal,

You can set the Output directory as a command line option, you can use os level variables to define the folder name and robot will create it for you

There are different tricks for generating a date time string that is filename safe depending on which os you are using and how you are running robot.

Dave.

Thanks Dave,

I’m working with windows 10 and running the robot in vs code in this way:
python -m robot -d results tests
Can you please give me an example of the tricks?

Gal

Hi Gal,

Sure, have a look at this: Building a date string in yyyy.mm.dd format in Batch (cmd.exe) | by Tech Notes | Medium

something like this is probably what you want:

python -m robot -d results tests %date:~10,4%%date:~4,2%%date:~7,2%-%time:~0,2%%time:~3,2%%time:~5,2%

That should give you YYYYMMDD-HHMMSS, but you can adjust it as you need,

Dave.

2 Likes