How to append todays timestamp in default created html report in robot framework

How to append todays timestamp in default created html report in robot framework

After execution robot framework create 3 files
log.html
output.xml
report.html

When we re-run it owerite the logs instead I want to create new log files by appending timestamp e.g. as below
log_2022_18_5.html
output.xml
report_2022_18_5.html

Where should be do code changes and how this can be achieved ?

Based on this FAQ question I’d say you need to try to:

Windows

-l log_%date:~-4,4%-%date:~-10,2%-%date:~-7,2%.html -r report_%date:~-4,4%-%date:~-10,2%-%date:~-7,2%.html

Linux and MacOS

-l log_`date +%F`.html -r report_`date +%F`.html

I tried above command on windows as below -
robottestscript.robot -l log_%date:~-4,4%-%date:~-10,2%-%date:~-7,2
%.html -r report_%date:~-4,4%-%date:~-10,2%-%date:~-7,2%.html

[ ERROR ] Parsing ‘-l’ failed: File or directory to execute does not exist.

Also Tried -
robot testscript.robot -d ./%date:~-4,4%%date:~-10,2%%date:~-7,2%
[ ERROR ] Parsing ‘-d’ failed: File or directory to execute does not exist.

I tried above but main thing I have to call robot script vai agent runner where I am not using any command to run. I am just calling robot.run() from script directory.

If you are not particularly interested in have same timestamp across 3 files (output, log, report) you could add -T flag to execution command.

@JaPyR
Would you mind sharing working command. I tried below but not working
robot testscript.robot -T

Options go before the tests/test suites:

C:\>robot --help
Robot Framework -- A generic automation framework

Version:  5.0.1 (Python 3.9.9 on win32)

Usage:  robot [options] paths
   or:  python -m robot [options] paths
   or:  python path/to/robot [options] paths

@HelioGuilherme66

I already tried this from script directory and not working
python -m robot test_script.robot
python -T robot test_script.robot
python -T robot test_script.robot -m

I am able to run script with simple command => robot test_script.robot but I want to add timestamp to be appended in generated html report file names.
currently its showing as log.html and report.html and overwriting same but it should be like below

e.g. report_2022_19_05.html or log_2022_19_05.html

Is this to hard to understand? Here is your command if you are in Linux or MacOS:

python -m robot -l log_`date +%F`.html -r report_`date +%F`.html  test_script.robot 

@HelioGuilherme66

Tried below command on windows , its running tests but not generated reports
python -m robot -l log_%date:~-4,4%-%date:~-10,2%-%date:~-7,2%.html -r report_%date:~-4,4%-%date:~-10,2%-%date:~-7,2%.html test_script.robot

It is not generating reports