"Item Count" property for CCs?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
kunkel321
Posts: 645
Joined: 10 Jun 2012 03:45
Location: Near Seattle

"Item Count" property for CCs?

Post by kunkel321 »

Hi Don,
If possible, please consider adding an "Item Count" special property for CCs... I'm referring to this thing from the Tree and List settings. Image
I tried using "File Count" but that is apparently something different.
What I'd like to is make a Mixed Column that is
IF image >> Dimensions
ELSE IF folder >> Item Count
ELSE >> Size.

Thanks. (This is a low-priority item--just something for your todo list 8) )

Also just an FYI, I noticed that when making a "Folder Only" CC, XYplorer automatically added the *.* to the filter section.
Image
Should it be an /*/ instead (??)
ste(phen|ve) kunkel

admin
Site Admin
Posts: 60632
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: "Item Count" property for CCs?

Post by admin »

Count: too slow, man!

*.* : good point!

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

Re: "Item Count" property for CCs?

Post by kunkel321 »

Even though counting the contents of folders could really slow things down with large directories... I still think it would be a worthy capability. What I would find really helpful is if number of subfolders and number of files could be shown. For example in this (bogus) shot:
Image

Maybe some of our script gurus can suggest how to script this?? :biggrin: :biggrin:
ste(phen|ve) kunkel

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: "Item Count" property for CCs?

Post by SkyFrontier »

Cool idea! :P

Code: Select all

   $tst = "<cc_isfolder>";
   if("$tst" == "0") {   }
   elseif("$tst" == "1") {
   $files = trim(folderreport("files", "r", "<cc_item>", ""), "<crlf>");
   $dirs = trim(folderreport("dirs", "r", "<cc_item>", ""), "<crlf>");
   $files = gettoken("$files", count, "<crlf>");
   $dirs = gettoken("$dirs", count, "<crlf>");
   return "Files: $files, Dirs: $dirs";
                         }
edit: yes, it takes some time to get a huge system folder drawn by using this. But it's cool, anyway!
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

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

Re: "Item Count" property for CCs?

Post by kunkel321 »

Thanks Sky!
It works like a charm. 8)
As you say (and as Don warned) it is quite sluggish if there are a hundred folders... But if there are only 10 or so, it's nearly instantaneous! :biggrin:
Incidentally, I now need help integrating it into a Mixed CC... But I'll post that as a different thread.
ste(phen|ve) kunkel

admin
Site Admin
Posts: 60632
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: "Item Count" property for CCs?

Post by admin »

Two remarks on style:

Why not simply this?

Code: Select all

if (<cc_isfolder> == 1) {
No need to quote variables. This is fine:

Code: Select all

$files = gettoken($files, count, <crlf>);

PeterH
Posts: 2785
Joined: 21 Nov 2005 20:39
Location: Germany

Re: "Item Count" property for CCs?

Post by PeterH »

admin wrote:No need to quote variables. This is fine:

Code: Select all

$files = gettoken($files, count, <crlf>);
Just to verify: count is a string, isn't it? Even in Help examples show count quoted as "count".

So does use count unquoted just work, or is it really correct syntax?
(At least there seems to be no remark saying that it's allowed.)


By the way: in help:

- gettoken() shows all operands as quoted - in Syntay as well as in Examples, while
- gettokenindex() shows operands quoted in Examples, while in Syntax separator and flags are shown unquoted...
(Sometimes users use a strange way of quoting :whistle: )
Win11 Pro 223H2 Gerrman

admin
Site Admin
Posts: 60632
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: "Item Count" property for CCs?

Post by admin »

Argh, of course you are right! :oops:

Code: Select all

$files = gettoken($files, "count", <crlf>);

admin
Site Admin
Posts: 60632
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: "Item Count" property for CCs?

Post by admin »

PeterH wrote:By the way: in help:

- gettoken() shows all operands as quoted - in Syntay as well as in Examples, while
- gettokenindex() shows operands quoted in Examples, while in Syntax separator and flags are shown unquoted...
(Sometimes users use a strange way of quoting :whistle: )
Well, I think that's okay to show it unquoted in the syntax. Saves space, and ultimately the climate.

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: "Item Count" property for CCs?

Post by SkyFrontier »

I've read somewhere that unquoted stuff could lead to unexpected results and quoting would make the scripts future-proof.
Can't say for sure if that was referring to attributing values to variables, though.
Thanks for the advices, guys.
(since it'll save me lots of typing, just hope I don't regret on this as I did with the commands deprecation cascade... :roll: )
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

admin
Site Admin
Posts: 60632
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: "Item Count" property for CCs?

Post by admin »

Don't worry. AFAIK no programming language in the world forces you to quote variables.

PeterH
Posts: 2785
Joined: 21 Nov 2005 20:39
Location: Germany

Re: "Item Count" property for CCs?

Post by PeterH »

SkyFrontier wrote:I've read somewhere that unquoted stuff could lead to unexpected results ...
I'd think a small misunderstandig :-)
It's not "unquoted stuff" but "unquoted strings"!
Strings have to be quoted, variables not. But: variables *may* appear inside of quotes, so instead of

Code: Select all

 $d = "string = '" . $str . "'!";
you *may* also write

Code: Select all

 $d = "string = '$str'!";
I hope this explains it a bit?
Win11 Pro 223H2 Gerrman

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: "Item Count" property for CCs?

Post by SkyFrontier »

Yes, it does!
Thanks much, Peter!
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

PeterH
Posts: 2785
Joined: 21 Nov 2005 20:39
Location: Germany

Re: "Item Count" property for CCs?

Post by PeterH »

SkyFrontier wrote:Yes, it does!
Thanks much, Peter!
...fine! :D
Win11 Pro 223H2 Gerrman

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: "Item Count" property for CCs?

Post by SkyFrontier »

...always wanted to see extensions each folder contains, right on list, without entering each one of them.
Now I can:

Code: Select all

   $files = trim(folderreport(files, r, <cc_item>, , , "<crlf>"), <crlf>);
   $exts = formatlist(regexreplace($files, ".+\.(.*)", $1), sde, <crlf>);
   $files = gettoken($files, count, <crlf>);
   return "$exts, F: $files";
(set FOLDERS as TYPE for this to work!)
It's just getting better, on and on...
:P
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

Post Reply