Page 1 of 1

Sub Folder Count

Posted: 06 Feb 2015 16:36
by nojttobba
Hi all,

Is there a way to get a count of sub-folders only in a parent directory? I'm sure this is possible in this great program.
Thanks for the help in advance.

nojttobba

Re: Sub Folder Count

Posted: 06 Feb 2015 17:30
by bdeshi
Only first-level subfolders or all folders regardless of level?

Get count of first-level subfolders only

If you just need the subfolder-count of a single folder, just select that folder and enter this code in the addressbar:

Code: Select all

::if(exists(<curitem>)==2){text "<curitem><crlf>contains ".(0 + listfolder(<curitem>,,34))." subfolders"}
you can also make XY show subfolder count in a dedicated column for all listed folders. Copy the following code, then ENTER ::snippet <clipboard>; in XY addressbar.

Code: Select all

Snip: CustomColumn 1
  
Action
  ConfigureColumn
Caption
  Subdir Count
Type
  3
Definition
  //returns count of first-level subfolders
   return 0 + listfolder(<cc_item>,,34);
Format
  2
Trigger
  0
Item Type
  1
Item Filter
  
a new custom column called Subdir Count will be generated. add that column to the filelist.

=============

Get total number of subfolders under the parent folder regardless of nesting level

Use these codes instead (note that these can be quite slow).
code for single folder info:

Code: Select all

::if(exists(<curitem>)==2){text "<curitem><crlf>contains ".gettoken(folderreport(dirsrel,r,<cc_item>,r,,'|'),count,'|')." subfolders"}
Code for the custom column:

Code: Select all

Snip: CustomColumn 1
  
Action
  ConfigureColumn
Caption
  Subdir Count
Type
  3
Definition
  //returns count of first-level subfolders
   return gettoken(folderreport(dirsrel,r,<cc_item>,r,,'|'),count,'|');
Format
  2
Trigger
  0
Item Type
  1
Item Filter
  
[edit.]

Re: Sub Folder Count

Posted: 06 Feb 2015 20:39
by nojttobba
Hi SammaySarkar,

Thanks for the help. It's greatly appreciated. To answer your question I was looking for only first-level subfolders.
I was able to create a new custom column based on your script. I dont see it the custom column list when I right click on the column headers. Only the first 5 are shown and the custom column is #12 on the list. How do I pick that one.

Thanks,
nojttobba

Re: Sub Folder Count

Posted: 06 Feb 2015 21:16
by Linkaday
Same indeed helpful Sammay (like so many others here) just posted a condensed but comprehensive HowTo in FAQs & Polls section
http://www.xyplorer.com/xyfc/viewtopic.php?f=10&t=13362

HTH

Re: Sub Folder Count

Posted: 06 Feb 2015 22:58
by kunkel321
Just today I was rebuilding some custom columns and had to look up this old post
http://www.xyplorer.com/xyfc/viewtopic. ... &start=135
:)