0

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.

2
Contributors
1
Reply
16
Views
3 Years
Discussion Span
Last Post by rojomoke
0

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

Edited by rojomoke

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.