* JavaExperts I want to make File count of many sub-folders inside main directory

Main > Sub 1
Main > Sub 2
Main > Sub 3

Sub 1 + Sub 2 + Sub 3 = Total
2015-03-15 07:14 · (0)
* Graham * JavaExperts This script assumes that all that is in /main is subfolders and a index file
and all the sub folders just contain 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

<!--parser:xtscript-->
var $flist=<xt:filelist folder="/main" 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="/main/$subf" />
var $total=($total+$subc-1)
var $start = ($end+1)
goto @loop
endif
print $total
<!--/parser:xtscript-->

Copy code
2015-03-15 09:53 (edited 2015-03-15 10:06 by Graham ) · (0)
* JavaExperts * Graham Dear brother i dont want to count folder i want to count files inside sub folder

Sub 1 > (files) + Sub 2 > (files) = total files (not folder)
2015-03-15 11:23 · (0)
* Graham * JavaExperts Thats just what the script does !!!
it returns the total of all the files in all the sub folders inside the main folder
same script turned into a function
http://syntax.xtgem.com/manual/basics/xtscripts/default?func=sub_folders_file_count
2015-03-15 12:15 (edited 2015-03-15 13:07 by Graham ) · (0)

Online: Guests: 1