Page 1 of 1

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

Posted: 12 Jul 2020 18:05
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

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

Posted: 12 Jul 2020 18:17
by highend

Code: Select all

return gettoken(readfile(<cc_item>), 1, <crlf>);

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

Posted: 12 Jul 2020 23:21
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

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

Posted: 10 Jan 2023 18:50
by python80
Thank you, very useful...
How about previewing first three lines of txt file?

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

Posted: 10 Jan 2023 19:11
by highend
return gettoken(readfile(<cc_item>), 3, <crlf>, , 1);?

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

Posted: 24 Jan 2023 18:06
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.

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

Posted: 24 Jan 2023 18:25
by highend
Use a regex to capture that part or just remove all other html tags and trim the result?

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

Posted: 24 Jan 2023 18:37
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?

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

Posted: 24 Jan 2023 19:10
by highend

Code: Select all

return regexreplace(regexmatches(gettoken(readfile(<cc_item>), 2, <crlf>), "<title>.*?</title>"), "<.+?>");
?