Batch to create a timestamp - DOS - Selenium RC

If you ever need a batch to create a timestamp.

@ECHO OFF
FOR /F "TOKENS=1* DELIMS= " %%A IN ('DATE/T') DO SET CDATE=%%B
FOR /F "TOKENS=1,2 eol=/ DELIMS=/ " %%A IN ('DATE/T') DO SET mm=%%B
FOR /F "TOKENS=1,2 DELIMS=/ eol=/" %%A IN ('echo %CDATE%') DO SET dd=%%B
FOR /F "TOKENS=2,3 DELIMS=/ " %%A IN ('echo %CDATE%') DO SET yyyy=%%B
SET datestamp=%yyyy%%dd%%mm%
SET timestamp=%time:~0,2%%time:~3,2%

echo %datestamp%.%timestamp%
pause

This can be used for selenium result file.

Here is how it is used:

@ECHO OFF
FOR /F "TOKENS=1* DELIMS= " %%A IN ('DATE/T') DO SET CDATE=%%B
FOR /F "TOKENS=1,2 eol=/ DELIMS=/ " %%A IN ('DATE/T') DO SET mm=%%B
FOR /F "TOKENS=1,2 DELIMS=/ eol=/" %%A IN ('echo %CDATE%') DO SET dd=%%B
FOR /F "TOKENS=2,3 DELIMS=/ " %%A IN ('echo %CDATE%') DO SET yyyy=%%B
SET datestamp=%yyyy%%dd%%mm%
SET timestamp=%time:~0,2%%time:~3,2%


c:
cd c:\selenium\selenium-remote-control-1.0.1\selenium-server-1.0.1
java -jar selenium-server.jar -port 4545 -firefoxProfileTemplate C:\Firefoxselenium -htmlSuite *chrome http://website.com// C:\selenium\TestSuite.html C:\selenium\TestResultsResults%datestamp%.%timestamp%.html
pause 

 

 

Here is another solution for creating the batch file.

@ECHO OFF
set hh=%time:~0,2%
if "%time:~0,1%"==" " set hh=0%hh:~1,1%
set  timestamp=%date:~10,4%-%date:~4,2%-%date:~7,2%__%hh%.%time:~3,2%.%time:~6,2%
echo %timestamp%

pause

This will overcome the issue of HH less than 10 am. you will not get a space like this " 930"

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by: wiki
Posted on: 2/2/2010 at 11:46 AM
Tags: ,
Categories: Software Testing
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed

Add comment


 

  Country flag

biuquote
  • Comment
  • Preview
Loading