Previewing 1st line of txt file as a custom column?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
Icecold
Posts: 2
Joined: 12 Jul 2020 17:56

Previewing 1st line of txt file as a custom column?

Post by Icecold »

Hi all,

Not sure this should have gone in this area or the scripting one, but I've decided to put it in here as to not clog up the scripting thread with what might be a basic question.

Is it possible to create a custom column which displays the 1st line of a .txt file? I know the "floating" or "quick" preview options exist, but they require me to flick through each file to get a preview. I have several hundered .txt files which I want to quickly be able to mentally process by being able to see their 1st sentence. Failing this, is it possible to bulk rename .txt files to the 1st line of their containing content?

Apologies if this is somewhat of a stupid question, but I've searched on both this forum and on google but can't seem to find anything on this.

Thank you

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

Re: Previewing 1st line of txt file as a custom column?

Post by highend »

Code: Select all

return gettoken(readfile(<cc_item>), 1, <crlf>);
One of my scripts helped you out? Please donate via Paypal

Icecold
Posts: 2
Joined: 12 Jul 2020 17:56

Re: Previewing 1st line of txt file as a custom column?

Post by Icecold »

Thanks a lot highend, I just tested it and it works great! Really appreciate the help, especially as you didn't need to go to the lengths of providing the actual code for me but still did! Time for me to go learn what each section of this code does by looking it up in the help manual :D

python80
Posts: 16
Joined: 08 Jul 2022 05:49

Re: Previewing 1st line of txt file as a custom column?

Post by python80 »

Thank you, very useful...
How about previewing first three lines of txt file?

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

Re: Previewing 1st line of txt file as a custom column?

Post by highend »

return gettoken(readfile(<cc_item>), 3, <crlf>, , 1);?
One of my scripts helped you out? Please donate via Paypal

python80
Posts: 16
Joined: 08 Jul 2022 05:49

Re: Previewing 1st line of txt file as a custom column?

Post by python80 »

highend wrote: 10 Jan 2023 19:11 return gettoken(readfile(<cc_item>), 3, <crlf>, , 1);?
It works, thank you very much.

My Custom Column:
return gettoken(readfile(<cc_item>), 2, <crlf>);

For my html file, custom column like this:
<html lang="tr-TR" dir="ltr"> <head> <meta charset="utf-8"> <title>XYplorer: File Manager for Windows</title> <!--ipt>

I want to see only title ("XYplorer: File Manager for Windows") in my custom column.
Is it possible?

Sorry for my bad English.

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

Re: Previewing 1st line of txt file as a custom column?

Post by highend »

Use a regex to capture that part or just remove all other html tags and trim the result?
One of my scripts helped you out? Please donate via Paypal

python80
Posts: 16
Joined: 08 Jul 2022 05:49

Re: Previewing 1st line of txt file as a custom column?

Post by python80 »

highend wrote: 24 Jan 2023 18:25 Use a regex to capture that part or just remove all other html tags and trim the result?
Both of them OK.
But how?

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

Re: Previewing 1st line of txt file as a custom column?

Post by highend »

Code: Select all

return regexreplace(regexmatches(gettoken(readfile(<cc_item>), 2, <crlf>), "<title>.*?</title>"), "<.+?>");
?
One of my scripts helped you out? Please donate via Paypal

Post Reply