Custom Columns File Name Character Count

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
dennydraco
Posts: 7
Joined: 25 Jul 2014 16:20

Custom Columns File Name Character Count

Post by dennydraco »

Hope this hasn't been posted previously, if so can someone direct me to it.

Can a custom column be made to give you the file name character count (with or without the file extension)?

Marco
Posts: 2354
Joined: 27 Jun 2011 15:20

Re: Custom Columns File Name Character Count

Post by Marco »

You mean that, given

Code: Select all

C:\folder\file.txt
the output should be 4?
Tag Backup - SimpleUpdater - XYplorer Messenger - The Unofficial XYplorer Archive - Everything in XYplorer
Don sees all [cit. from viewtopic.php?p=124094#p124094]

dennydraco
Posts: 7
Joined: 25 Jul 2014 16:20

Re: Custom Columns File Name Character Count

Post by dennydraco »

yes, exactly

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

Re: Custom Columns File Name Character Count

Post by bdeshi »

enter ::snippet; in addressbar and paste this code to create the column definition as NameLen.

Code: Select all

Snip: CustomColumn 1
  XYplorer 14.30.0301, 7/25/2014 8:42:13 PM
Action
  ConfigureColumn
Caption
  NameLen
Type
  3
Definition
   $n = strlen(<cc_name>);
   if <cc_ext> != '' {$r = "/".($n - strlen(<cc_ext>) -1);}
   else {$r = "/".$n;}
  return $n$r;
Format
  0
Trigger
  1
Item Type
  2
Item Filter
  
[/size]It's return value is like this: <length of name with ext>/<length of name without ext>

If you don't want it to apply to folders, then select "Files" as the coulmns itemtype. Also in this case, the script may be highly simplified.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

dennydraco
Posts: 7
Joined: 25 Jul 2014 16:20

Re: Custom Columns File Name Character Count

Post by dennydraco »

Thanks for the script. That's what I needed. :beer:

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

Re: Custom Columns File Name Character Count

Post by bdeshi »

:beer:
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

Post Reply