john pfeiffer
  • Home
  • Categories
  • Tags
  • Archives

BAT file for loop count timestamp

@echo off

SET SECONDS=20
SET TARGET=O:\2011-10-07-small-file-test
REM SET TARGET=c:\USERS\user\Desktop

FOR /L %%A IN (1,1,4320) DO (

  CALL :CREATETIMESTAMP
  echo %date% %time%
  echo %TARGET% -- %TIMESTAMP%
  CALL :DRIP

  echo "wait %SECONDS% seconds"
  ping -n %SECONDS% 127.0.0.1 > null

)


GOTO :EOF


REM - - FUNCTION DEFINITIONS  - - - - - - - - - - - -

:CREATETIMESTAMP
  SET THEDATE=%date%
  SET THEYEAR=%thedate:~-4%
  SET themonth=%thedate:~4,2%
  SET theday=%thedate:~7,2%
  SET hyphen=-
  SET filedate=%theyear%%hyphen%%themonth%%hyphen%%theday%

  SET thetime=%time%
  SET thehour=%thetime:~1,1%
  SET theminute=%thetime:~3,2%
  SET THESECOND=%thetime:~6,2%
  SET underscore=_

  SET TIMESTAMP=%filedate%%hyphen%%hyphen%%thehour%%hyphen%%theminute%%hyphen%%thesecond%

GOTO :EOF


:DRIP
  echo %thetime% > %TARGET%\%TIMESTAMP%-file1.txt
  echo %thetime% > %TARGET%\%TIMESTAMP%-file2.txt
  echo %thetime% > %TARGET%\%TIMESTAMP%-file3.txt
  echo %thetime% > %TARGET%\%TIMESTAMP%-file4.txt
  echo "wait %SECONDS% seconds"
  ping -n %SECONDS% 127.0.0.1 > null
GOTO :EOF

  • « BAT automated testing
  • BAT delete folder files recursive search »

Published

Feb 7, 2012

Category

bat-vbs-perl

~96 words

Tags

  • bat 22
  • bat-vbs-perl 51
  • count 6
  • file 92
  • for 18
  • loop 9
  • timestamp 3