Sub Folder Count

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
nojttobba
Posts: 2
Joined: 06 Feb 2015 16:28

Sub Folder Count

Post 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

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: Sub Folder Count

Post 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.]
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

nojttobba
Posts: 2
Joined: 06 Feb 2015 16:28

Re: Sub Folder Count

Post 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

Linkaday
Posts: 392
Joined: 06 Aug 2007 14:40
Location: Hamburg, Germany - Win 11 Home v25H2 x64 1920x1080 (100%)

Re: Sub Folder Count

Post 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

kunkel321
Posts: 664
Joined: 10 Jun 2012 03:45
Location: Near Seattle

Re: Sub Folder Count

Post 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
:)
ste(phen|ve) kunkel
Scaling: Main monitor 125%, Secondary monitor on the right 100%
OS: Win 10. XYplorer version: Latest beta, unless specified.

Post Reply