Melodeon.net Forums

Discussions => Tunes => ABC => Topic started by: Andy Next Tune on November 05, 2015, 08:14:10 PM

Title: Creating an index
Post by: Andy Next Tune on November 05, 2015, 08:14:10 PM
I maintain our band's tunebook in an ever expanding ABC file.
It is organised/sorted into dance sets and tune types by structured use of the X: field.

My challenge is to find a straight-forward mechanism to produce from the ABC file a complete alpha list of tunes referencing the X field.

Any suggestions?

BTW I use ABCExplorer/Windows10.
Title: Re: Creating an index
Post by: Jack Campin on November 05, 2015, 09:00:45 PM
BarFly (for old Macs) lets you extract header fields of your choice into a tab-separated file.

You could program something like that quite easily in Unix using the standard text processing utilities. If you have Perl you should be able to do the same sort of thing with much greater obscurity.

Or get Python. It's a lot more readable and somebody here must know it.
Title: Re: Creating an index
Post by: Anahata on November 05, 2015, 11:01:32 PM
You could program something like that quite easily in Unix

If the abc files are all in the same directory tree and you are in the root of that tree, all you need is:
Code: [Select]
grep -r ^T: . >abcindex.txt (lots of variations on this are possible)
Title: Re: Creating an index
Post by: Chris Ryall on November 06, 2015, 09:20:06 AM
   
    grep -r ^T: . >abcindex.txt

    (lots of variations on this are possible)

Gosh, is it THAT easy? ::)

  (And wasn't Grep the chap that wrote Enigma Variations)?
Title: Re: Creating an index
Post by: Lester on November 06, 2015, 09:23:55 AM
What I do for my band work is:

Open the band.abc in LibreOffice (cheapskate Word).
Use it to put a page break before each X: to get a tune a page.
Then apply a H1 style to each line starting T:.
Auto generate an Table of Contents.
Export the whole shooting match to PDF which I view, via DropBox, on my tablet should I need it during bookings.

Not exactly what you want but should give you some ideas  ;)
Title: Re: Creating an index
Post by: Andy Next Tune on November 06, 2015, 09:39:05 AM
Thanks Anahata, Jack.

Unfortunately I do not have Unix/Linux (everything is on Windows10), and programming with perl, Python etc is not a current skill.

But the comment about BarFly extracting headers pushed me to re-check ABCExplorer again. And it has a similar function...

Under Tools, there is a utility to Extract Field Contents..... , including a button (I missed it previously) to export 'full index to a Text file'.
The resulting file cross-references the selected field e.g. T: to the X: field - just what I was looking for!

Interestingly, it would appear that the index file generated is for all ABC files open in ABCExplorer at that time. So if you have a number of large ABC archives, as I have, then it provides a simple mechanism to create a consolidated or meta index.

Title: Re: Creating an index
Post by: Anahata on November 06, 2015, 12:24:58 PM
The Mac has a unix-like operating system, which leads to the ironic conclusion that OSX can be recommended over Windows because of its superior command line interface  :o

Windows does have a command line (I'm sure it's still there even in W10) and the FIND command, but most Windows command line programs (even though they've got better since DOS) are hopelessly inadequate and lacking in joined-up thinking.

    grep -r ^T: . >abcindex.txt
    (lots of variations on this are possible)
Gosh, is it THAT easy? ::)

The thing is, once you've figured it out, you can put that into a one-line script or alias and the next time you want to use it all you have to remember is what you called it.
Title: Re: Creating an index
Post by: syale on November 07, 2015, 01:52:29 AM
Powershell is much more script friendly than DOS!

http://blogs.msdn.com/b/powershell/archive/2008/03/23/select-string-and-grep.aspx (http://blogs.msdn.com/b/powershell/archive/2008/03/23/select-string-and-grep.aspx)

Stephen
SimplePortal 2.3.5 © 2008-2012, SimplePortal