Showing posts with label batch. Show all posts
Showing posts with label batch. Show all posts

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...

Monday, December 5, 2011

TIP - How to check an errorlevel of a program...

First understand a little about error levels... Batch files - Errorlevels:

Next... Write this code the a batch file and run it (change the runme.exe to the program that you wish to check the error-level).
#~~~~~~~~~~~~~~~~~~~~~~~~~
runme.exe
ECHO.%ERRORLEVEL%
PAUSE
#~~~~~~~~~~~~~~~~~~~~~~~~~

Hope it helps...

Wednesday, September 28, 2011

Bat To Exe Converter

Here is an example of requierments:

  • Create a script that automate blabla.... (I've presented a batch file after an hour or so).
After 5 sec:
  • The script will be presented to out client as an exe file.


Well, here is the tool I used for the job: Bat To Exe Converter

Other utils that might come handy: