Posts Tagged ‘for loop’

Empty variables during FOR loops in batch files

Written by Ingmar Verheij on April 27th, 2010. Posted in Batch

Batch files (*.bat / *.cmd) are easy to build and yet powerful scripts .
Although time is catching up and batch files are more and more replaced by vbScript and PowerShell, there are occasions you need them.
Batch files are especially powerful when you’re using (for) loops and variables. But the combination of those two is somewhat of a problem. Why? It doesn’t (seem to) work…
Let’s take the following situation.
You want to build a script that searches for files with a given extension in a given directory. You then strip the extension of the filename and process the file. This script would look like this:

Donate