Nested Token search batch file
<p>I have a batch file I am working on trying to use to achieve up IIS server logs. Here is the details of all files involved and the final output I am seeing</p>

<p>Batch file:</p>

<pre><code>setlocal
set zipfolder=D:\Statscheck\zipped\
set statsdir=D:\Statscheck\
set statsfolder=Statscheck
d:
cd\
cd\%statsfolder%
dir w3* /s /b &gt; d:\server-scripts\temp\process.txt
set THECSVFILE=d:\server-scripts\temp\process.txt

::read %THECSVFILE% and loop through each line
for /F "usebackq tokens=* delims=\" %%A in (%THECSVFILE%) do (
    set dirname=%%A
)
for /F "usebackq tokens=3 delims=\" %%A in (%THECSVFILE%) do (
    set filename=%%A
    call :process_line
)
:process_line
set buildfile= %zipfolder%stats-%filename%-archive.zip
echo filename %buildfile% &gt;&gt;D:\server-scripts\temp\output.txt
echo directory %dirname% &gt;&gt;D:\server-scripts\temp\output.txt
</code></pre>

<hr>

<p><code>Process.txt</code>:</p>

<pre><code>D:\Statscheck\dphs92\W3SVC1532191319
D:\Statscheck\kcnw\W3SVC232480661
D:\Statscheck\master\W3SVC84257322
D:\Statscheck\warlords\W3SVC1913965975
</code></pre>

<p><code>output.txt</code>:</p>

<pre><code>filename  D:\Statscheck\zipped\stats-dphs92-archive.zip 
directory D:\Statscheck\warlords\W3SVC1913965975 
filename  D:\Statscheck\zipped\stats-kcnw-archive.zip 
directory D:\Statscheck\warlords\W3SVC1913965975 
filename  D:\Statscheck\zipped\stats-master-archive.zip 
directory D:\Statscheck\warlords\W3SVC1913965975 
filename  D:\Statscheck\zipped\stats-warlords-archive.zip 
directory D:\Statscheck\warlords\W3SVC1913965975 
</code></pre>

<p>As you can see from the output it is building the filename option correctly however the directory that is being pulled is the last one in the list. Is it not looping.</p>