|
|||||||
![]() |
|
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
|
#1 |
|
Junior Member
Join Date: May 2009
Posts: 14
|
Get the count of total number of files under a folder.
Hi,
What is the script to get the count of files under a folder? Please advice. Thanks in advance, Regards, John. |
|
|
|
|
|
#2 |
|
Member
Join Date: Jan 2011
Posts: 69
|
:-)
As a famous philosoph said a long time ago: "RTFM!"
![]() Joke... But exactly there is the answer. Keyword: "File Functions Header" code: have fun cheers |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Oct 2007
Location: Shanghai, China
Posts: 207
|
Contact me: 137729898@qq.com |
|
|
|
|
|
#4 |
|
Major Dude
Join Date: Mar 2003
Posts: 571
|
The NSIS User Manual has some appendices describing lots of useful functions together with sample code showing how to use them.
Appendix E.1 (File Functions Header) includes the GetSize function which can be used to count the number of files in a folder or in a folder and its sub-folders: http://nsis.sourceforge.net/Docs/AppendixE.html#E.1.3 |
|
|
|
|
|
#5 |
|
Major Dude
Join Date: Oct 2006
Posts: 1,892
|
Or if you don't need recursive searches, you can just use something simple like this:
PHP Code:
|
|
|
|
|
|
#6 |
|
Moderator
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
|
You need to ignore $1 if it is . or ..:
Stucode: |
|
|
|
|
|
#7 |
|
Major Dude
Join Date: Oct 2006
Posts: 1,892
|
I don't see how it would count the files from parent. It would simply add two counts to $dirs. FindFirst/Next isn't recursive, either down or up the tree. You can solve the two extra counts by using StrCpy $dirs -2 at the beginning, instead of 0. Saves a bunch of Ifs (but probably breaks if the search directory doesn't exist).
|
|
|
|
|
|
#8 |
|
Moderator
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
|
Sorry you are right of course. Fixed the error with the FileExist check ($1 is only the file name, not the complete path).
Stu |
|
|
|
![]() |
|
|||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|