Tuesday, December 6, 2011

TIP: Creating a file, fast, with incremental values (using FOR /L).

I needed to create a file (called urls.txt) that contains lots of image urls, here is the solution:


  1. Create a batch file (I'll call it gget.bat).
  2. copy and paste the following to gget.bat file.

REM ~~~~~ gget.bat file content ~~~~~~~~~~~~~~~

@echo off
for /L %%a in (0,1,1984) do (
echo http://domain.com/images/%%a.jpg >>c:\urls.txt
)

ECHO DONE!
pause
REM ~~~~~ gget.bat file content ~~~~~~~~~~~~~~~


  1. change the numbers in "(0,1,1984)" to the desired ones (please read more about 'FOR /L' here.).
the result is a file 'c:\urls.txt' that contains this:

http://domain.com/images//0.jpg 
http://domain.com/images//1.jpg 
http://domain.com/images//2.jpg 
http://domain.com/images//3.jpg 
...
http://domain.com/images//1983.jpg 
http://domain.com/images//1984.jpg 

Hope it helps...

No comments:

Post a Comment