Reputation: 68
At the end of every robot execution I want to put the files: Log.xml, Report.xml, Output.xml in a unique timestamped directory.
My script timestamps the files, but I don't really want that, just the default file names inside a timestamped directory after each execution?
This is my current script:
CALL "C:\Python27\Scripts\robot.bat" --variable BROWSER:IE --outputdir C:\robot\ --timestampoutputs --name "Robot Execution" Tests\test1.robot
Upvotes: 1
Views: 519
Reputation: 6981
The timestamp needs to be generated within the Batch script. Robot Framework will generate the complete path should it not yet exist. This includes all parent folders as well.
As we stand upon the shoulders of giants, so does this answer in the form of the Stack Overflow answer that provides the below script bar the last two lines
@echo off
SETLOCAL ENABLEDELAYEDEXPANSION
:: put your desired field delimiter here.
:: for example, setting DELIMITER to a hyphen will separate fields like so:
:: yyyy-MM-dd_hh-mm-ss
::
:: setting DELIMITER to nothing will output like so:
:: yyyyMMdd_hhmmss
::
SET DELIMITER=%1
SET DATESTRING=%date:~-4,4%%DELIMITER%%date:~-7,2%%DELIMITER%%date:~-10,2%
SET TIMESTRING=%TIME%
::TRIM OFF the LAST 3 characters of TIMESTRING, which is the decimal point and hundredths of a second
set TIMESTRING=%TIMESTRING:~0,-3%
:: Replace colons from TIMESTRING with DELIMITER
SET TIMESTRING=%TIMESTRING::=!DELIMITER!%
:: if there is a preceeding space substitute with a zero
SET DATETIMESTAMP=%DATESTRING%_%TIMESTRING: =0%
CALL robot --variable BROWSER:IE --outputdir ./%DATETIMESTAMP%/ --name "Robot Execution" ./test.robot
Upvotes: 3