Reader Nathan Casselton asked about using my program, snapz.exe (described in a previous post), to capture multiple images using a sequence of numbered filenames (e.g. '1.dib', '2.dib', '3.dib', etc.)
It is possible to do something like this without modifying the snapz application itself. It can simply be packaged up in a batch file as I show below. A good starting point is to show how snapz can be used to capture an image under a different filename than the default one ('snapz.dib'). To do this, use a command like the following:
snapz.exe & rename snapz.dib newfile.dib
This is really two commands in a single line. The first command is 'snapz.exe', which captures an image and stores it as 'snapz.dib'. The second command is 'rename snapz.dib newfile.dib', which renames the captured file as 'newfile.dib'. Naturally, you can use whatever filename you want here. The ampersand (that’s the ‘&’ symbol) is simply used to ensure that each of the two commands is interpreted in isolation, even though they share a single line.
Now that we can assign any filename we want to the images captured by snapz, it’s possible to wrap it up in a batch file that captures multiple images under numbered filenames using a DOS for loop. Here’s the batch file I’ve come up with:
FOR /L %%i IN (1,1,5) DO ( snapz.exe rename snapz.dib %%i.dib sleep 1 )
To run this script, just save it as a '.bat' file (I called mine 'sequence.bat'), in the same directory as snapz.exe. To run the script, just type 'sequence'. My example captures five images to filenames numbered 1 to 5. If you wish to capture more (or less) images, just change the number ‘5’ in the first line. I’ve also included the command ‘sleep 1’ in the loop to create an extra one-second delay between snapshots. You can change the number ‘1’ to create a longer delay. Alternatively, to take the sequence of snapshots as quickly as possible, just remove the sleep line altogether.