Tuesday, January 15, 2013

Create sample input using windows batch file


Script that did my job

-------------------------------------------

@echo off

setlocal EnableDelayedExpansion

for /L %%F IN (1,1,100) DO (
set /a year = !RANDOM! %% 12+2000
echo !year! !RANDOM!
)

endlocal
-------------------------------------------

Generates random numbers. First column contains year between 2000 to 2012 second column contains a random number. You would have to tweak for your requirement.

Did your day just got saved? ! :)

Oh and by the way you can direct your output to a text file as
<filename>.cmd > mysampleinput.txt

:p


References

  1. http://ss64.com/nt/set.html
  2. http://www.bish.co.uk/forum/index.php?topic=58.0
  3. http://stackoverflow.com/questions/3439626/windows-batch-file-calculating-filename-from-current-date

No comments:

Post a Comment

I would be glad to know if this post helped you.