Improvement on custom column script

Discuss and share scripts and script files...
Post Reply
Akane2092
Posts: 5
Joined: 12 Jul 2025 03:42

Improvement on custom column script

Post by Akane2092 »

Greeting, XY mates!

I wrote a script for a custom column that draws circle based on the existence of specific file types inside a folder:

Code: Select all

"Draw Circle based on attachments"
  $content = folderreport("files:{name}", "r", "<cc_item>");
  $drawCmd = "";
  if (regexmatches($content, ".ppt")) { $drawCmd = $drawCmd . "20, C43E1C, 200, 0,  0; ";}
  if (regexmatches($content, ".doc")) { $drawCmd = $drawCmd . "20, 2B579A, 200, 0, 25; ";}
  if (regexmatches($content, ".xls")) { $drawCmd = $drawCmd . "20, 185C37, 200, 0, 50; ";}
  if (regexmatches($content, ".pdf")) { $drawCmd = $drawCmd . "20, B30B00, 200, 0, 75; ";}
  if ($drawCmd == "") { 
    return ">draw.circle 20, 000000, 1, 0"; 
  } else {
    return ">draw.circle $drawCmd"; 
  }
The script works OK, but it is a bit slow to load when there are many folders.
So I am asking you pro-scriptors whether there is a better way to achieve the same result.
Cheers!

highend
Posts: 14426
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Improvement on custom column script

Post by highend »

quicksearch() is faster than listfolder() and way faster than folderreport()
strpos() is faster than regexmatches() but less precise (which shouldn't really matter, your regex was wrong anyway: \.ppt$)

Code: Select all

  $content = quicksearch("*doc;*.pdf;*.ppt;*.xls /nf", <cc_item>);
  $drawCmd = "";
  if (strpos($content, ".ppt") != -1) { $drawCmd .= "20, C43E1C, 200, 0,  0; ";}
  if (strpos($content, ".doc") != -1) { $drawCmd .= "20, 2B579A, 200, 0, 25; ";}
  if (strpos($content, ".xls") != -1) { $drawCmd .= "20, 185C37, 200, 0, 50; ";}
  if (strpos($content, ".pdf") != -1) { $drawCmd .= "20, B30B00, 200, 0, 75; ";}
  if ($drawCmd == "") {
    return ">draw.circle 20, 000000, 1, 0";
  } else {
    return ">draw.circle $drawCmd";
  }
One of my scripts helped you out? Please donate via Paypal

Akane2092
Posts: 5
Joined: 12 Jul 2025 03:42

Re: Improvement on custom column script

Post by Akane2092 »

Wow! Just tested it. Works lightning fast
Thank you so much! Have a nice day.

Post Reply