sub folders file count
Count the files in sub folders
This script assumes that all that is in /main is sub folders and a index file
And all the sub folders contain only the files being counted and a index file
if the sub folders do not contain a index file change the maths to
var $total=($total+$subc)
Beware of timeouts on very large main folders and sub folders
Example code
Show in textarea<!--parser:xtscript-->
function subcount $folder
var $flist=<xt:filelist folder="/$folder" template="|.file_name." filter="-index*"/>|
var $start=1
@loop
var $end = call strpos $haystack=$flist;$needle=|;$offset=($start+1);
if $end >0
var $subf = call substr $val=$flist;$start=$start;$length=($end-$start)
var $subc = <xt:filecount folder="/$folder/$subf" />
var $total=($total+$subc-1)
var $start = ($end+1)
goto @loop
endif
return $total
endfunction
print <hr />The sub folders in <i>/main/</i> contain ;
call subcount $folder=main
print files in total
<!--/parser:xtscript-->
Show in textarea Example output
Reload
The sub folders in
/main/ contain 14 files in total