Tip: Populate a custom column with text file content

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
highend
Posts: 14956
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Tip: Populate a custom column with text file content

Post by highend »

Let's assume you have a (txt) file with file names and some kind of description for each of it's entries
and you want to populate a custom column with the descriptions...

Like:

Code: Select all

E:\2015_1231_00_50_13_354.png|Anna
E:\2016_0102_16_33_22_124.png|Jamie
E:\2016_0103_00_58_57_317.png|Irina
E:\2016_0105_21_12_17_466.png|Hanna v2
E:\2016_0106_06_16_11_884.png|Miami
Normally you'd parse this file for each single entry in the list pane with a custom column script so with each additional file
the time to display everything rises.

Just a short tip to speed up the whole thing:

Code: Select all

    perm $P_ColumnContent;
    if !($P_ColumnContent) { $P_ColumnContent = readfile("the full path to the file that contains the content.txt"); }
    $index = gettokenindex(<cc_item>, regexreplace($P_ColumnContent, "\|.*?(?=$)"), <crlf>, "i");
    return gettoken(gettoken($P_ColumnContent, $index, <crlf>), 2, "|");
This custom column script reads the file only once, populates a permanent variable with it and from then on each other
column entry parses only the variable's content.

For gaining the boost you have to pay a small price: If you want to reread everything because you modified
the text file you need a short script:

Code: Select all

    perm $P_ColumnContent = "";
    #485; // Refresh list
One of my scripts helped you out? Please donate via Paypal

Post Reply