Skip to content
⌘ NSIS Forum Archive

File count

3 posts

CDante#

File count

Hello,

Is there a quick and easy way to count the number of files in a directory (including sub-dirs)?

Couldn't find anything useful in the help doc or the forum.

Thanks in advance!
-CDante
Red Wine#
Quick and easy as possible, in combination with RecFind.nsh:

OutFile 'files_counter.exe'
showinstdetails show
installdir $WINDIR

!include RecFind.nsh

var counter

page directory
page instfiles

Section

strcpy '$counter' '0'

${RecFindOpen} "$INSTDIR" $R0 $R1
${RecFindFirst}
intop '$counter' '$counter' + '1'
detailprint "file(s) found: $counter"
${RecFindNext}
${RecFindClose}

detailprint "total files: $counter"
SectionEnd