Hi,

I have a snippet of batch code that searches through a folder and outputs the results one file per line in html format.

Code below:

@ECHO OFF &SETLOCAL

(FOR /f "delims=" %%a IN ('dir /b /a-d /s /n "C:\Documents and Settings\All Users\Documents\My Pictures\Pics & Vids"') DO (
    FOR /f "tokens=1-3*" %%x IN ('dir /a-d /tc "%%~a"^|findstr "^[0-9]"') DO (
       ECHO ^<img src="%%a" width="20px" border="2"^>^<a href="%%a"^>%%~nxa^</a^>,%%~ta,%%x ^</br^>

    )  
))>DIR.html
TYPE DIR.html

I am trying to code in a counter so that each line starts woith the initial file count, i.e. the first line would start with 1 and each successive line this number would increase by 1 etc...

Now, I have initially come up with:

@ECHO OFF &SETLOCAL
Set Counter = 0

to set the counter start to zero.

I know how to change the ECHO line to display the Counter:

ECHO %Counter%^<img src="%%a" width="20px" border="2"^>^<a href="%%a"^>%%~nxa^</a^>,%%~ta,%%x ^</br^>

but I cannot work out where the code for increasing the counter should go:

Set Counter = Counter + 1

Everywhere I seem to have tried only outputs a zero on each line.

Any help would be appreciated.

Regards.

You actually need let counter=0 to initialise and let counter=counter+1 to increment. Note the lack of spaces in the expressions.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.