<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="application/vnd.wap.xhtml+xml; charset=utf-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1" />
    <title>XtGem.com</title>
</head>
<body style=""><div class="xt_container" data-xtcontainer="heading" style="text-align: left;"><xt:text><h2 style="display:block;text-align: center;">File count</h2></xt:text></div>
<div class="xt_container" data-xtcontainer="code"><xt:text>A simple Xtscript function to show the number of files in a folder<br />
Add the Xtscript anywhere on the page and then call it from your html</xt:text><xt:code><div class="xt_textarea">
<textarea style="height:8em" class="notranslate">&lt;!--parser:xtscript--&gt;
function fcount $path=/;$filter=-index
assign $list = &lt;xt:filelist folder=&quot;$path&quot; template=&quot;*&quot; filter=&quot;$filter&quot; /&gt;
call strlen $val=$list
endfunction
&lt;!--/parser:xtscript--&gt;</textarea>
</div></xt:code><xt:text>Then call the function in the link to the folders index<br />
Set your own folder and filter<br />
defaults are root(main) folder and do not count the index file</xt:text><br /><xt:code><div class="xt_textarea">
<textarea style="height:3em" class="notranslate">&lt;xt:call function=&quot;fcount&quot; path=&quot;/YOUR_FOLDER&quot; filter=&quot;FILTER&quot; /&gt;</textarea>
</div></xt:code><xt:text><span style="color: #ff0;">NOTE:<br />
If you are not going to set your own filter leave the filter=&quot;...&quot; parameter out of the function call</span></xt:text><xt:code><div class="xt_textarea">
<textarea style="height:3em" class="notranslate">&lt;xt:call function=&quot;fcount&quot; path=&quot;/YOUR_FOLDER&quot; /&gt;</textarea>
</div></xt:code></div>
    <div data-xtcontainer="xtscript" class="xt_container" style=""><xt:text><h4 style="display:block;text-align: center;">Example output</h4></xt:text><xt:code><!--parser:xtscript-->
function fcount $path=/  ; $filter=-index
assign $list = <xt:filelist folder="$path" template="*" filter="$filter"  />
call strlen $val=$list
endfunction
call fcount
<!--/parser:xtscript-->
<a href="/manual/files/smile">smilies </a> (<xt:call function="fcount" path="/manual/files/smile" />)<br />
<a href="/manual/xtgem/folder">files</a> (<xt:call function="fcount" args="$path=manual/xtgem/folder" />)<br />

</xt:code>
    </div>
</body>
</html>
