Noude
16th August 2010 09:39 UTC
Count files
Hello !
Please, I have to count how many files I have in a directory.
Is there a special function to do this or not ?
I don't find any answers on the Internet =( (and in the doc)
And if it's possible I want to have there name too ^^
Thanks for help !
MSG
16th August 2010 10:10 UTC
Please read the manual under 'File Instructions'.
http://nsis.sourceforge.net/Docs/Chapter4.html#4.9.5.13
Yathosho
16th August 2010 10:18 UTC
you can also use the locate function if you need a number of filters and support for subdirs
Noude
16th August 2010 10:24 UTC
thanks for your answers, but I don't think I need to have a number of filters.
MSG: Yes I already read this section of the manual, but I think I don't really understand how it can helps me (I think because of my bad English but...)
Afrow UK
16th August 2010 11:58 UTC
StrCpy $Counter 0
ClearErrors
FindFirst $R0 $R1 $DIR\*.*
${DoUntil} ${Errors}
${If} $R1 != .
${AndIf} $R1 != ..
${AndIfNot} ${FileExists} $DIR\$R1\*.*
IntOp $Counter $Counter + 1
${EndIf}
FindNext $R0 $R1
${Loop}
FindClose $R0
Stu
MSG
16th August 2010 11:59 UTC
Use LogicLib to create a loop where you FindNext until you reach the last file. Maybe add in a check to see whether an entry is really a filename and not a subdirectory (not sure if FindNext finds directories, you'd have to try).
ps: With "a number of filters" Yatasho means "several filters", not "the actual number of existing filters", or anything like that. >_>
edit: too late. :)
Noude
16th August 2010 13:13 UTC
Thanks to all ! =)
It's working now :)