<p>I have a set of base filenames, for each name 'f' there are exactly two files, 'f.in' and 'f.out'.  I want to write a batch file (in Windows XP) which goes through all the filenames, for each one it should:</p>

<ul>
<li>Display the base name 'f'</li>
<li>Perform an action on 'f.in'</li>
<li>Perform another action on 'f.out'</li>
</ul>

<p>I don't have any way to list the set of base filenames, other than to search for *.in (or *.out) for example.</p>

Easiest way, as I see it, is to use a for loop that calls a second batch file for processing, passing that second file the base name.
According to the for /? help, basename can be extracted using the nifty ~n option. So, the base script would read:
```
```
for %%f in (*.in) do call process.cmd %%~nf
```
```
Then, in process.cmd, assume that %0 contains the base name and act accordingly. For example:
```
```
echo The file is %0
copy %0.in %0.out
ren %0.out monkeys_are_cool.txt
```
```
There might be a better  way to do this in one script, but I've always been a bit hazy on how to pull of multiple commands in a single for loop in a batch file.
EDIT: That's fantastic! I had somehow missed the page in the docs that showed that you could do multi-line blocks in a FOR loop. I am going to go have to go back and rewrite some batch files now...