[Linux] Utility to Sort abc tunebook by tune name?

For discussing abc notation software
rlindau
Posts: 1
Joined: Fri Dec 03, 2010 2:33 am
Humanity check: a real person
How many letters in "spam" (4)?: 3

[Linux] Utility to Sort abc tunebook by tune name?

Postby rlindau » Fri Dec 03, 2010 2:52 am

I'm seeking an app (linux or web - or possibly a dos/windows app that might run under wine) that will let me sort my abc tunebooks. Any ideas?

Some background: I'm running Linux Mint 10 (~Ubuntu 10.10) with wine 1.3.8. I had used abc2win for years, and was able to get it work after I switched to linux (running it under wine), but but I can no longer get it to run with my current linux/wine release. I'm now trying out ABCJ as my main abc tool. There's a lot I like about ABCJ, but (unless I'm wacko) ABCJ can't sort tunebooks in tune name sequence (or, to sort the tune list display in name sequence, leaving the tunebook itself alone).

I guess I could use my text editor, but that would be a real pain-in-the-you-know-what.

Regards, Rob L

michel.isard
Posts: 7
Joined: Mon Jan 03, 2011 8:45 pm
Humanity check: a real person
How many letters in "spam" (4)?: 3

Re: [Linux] Utility to Sort abc tunebook by tune name?

Postby michel.isard » Sat Jan 08, 2011 11:02 am

I hope have understood you request.

Please find enclosed an archive with to scripts and test files.

Usage :
- Unzip the archive
- Open the distrib directory
- Copy in it the abc file to be sorted
- in a shell type vim followed by the name of this file
- once vim lauched, type :so sort-titles.ex (double dot followed by 'sort-titles.ex')
- _wait end of messages_
- vim quits automatically and saves the output in a file named 'sorted_' followed by the name of the file

Warning : This script removes the texts aroung the tunes !
Compare the test file and the output to see the differences.

If you like, you can renumber X: fields with the RenumXFields.sh utility

Once in the distrib directory, in a shell type :

./RenumXFields.sh your-abc-filename

the name of output is 'renumbered_' followed by the name of the file

Warning : this utility works only with UNIX line end format
Before using with DOS or MAC file, convert it to UNIX

WARNING !!!! these scripts are not *fully* tested : keep a copy of the original files !!!!
Attachments
SortBook-V.2-distrib.tar.gz
(63.68 KiB) Downloaded 302 times

jimm1909
Posts: 1
Joined: Tue Apr 03, 2012 12:07 am
Humanity check: a real person
How many letters in "spam" (4)?: 3

Re: [Linux] Utility to Sort abc tunebook by tune name?

Postby jimm1909 » Tue Apr 03, 2012 12:08 am

rlindau wrote:I'm seeking an app (linux or web - or possibly a dos/windows app that might run under wine) that will let me sort my abc tunebooks. Any ideas?

Some background: I'm running Linux Mint 10 (~Ubuntu 10.10) with wine 1.3.8. I had used abc2win for years, and was able to get it work after I switched to linux (running it under wine), but but I can no longer get it to run with my current linux/wine release. I'm now trying out ABCJ as my main abc tool. There's a lot I like about ABCJ, but (unless I'm wacko) ABCJ can't sort tunebooks in tune name sequence (or, to sort the tune list display in name sequence, leaving the tunebook itself alone).

I guess I could use my text editor, but that would be a real pain-in-the-you-know-what.

Regards, Rob L


Did you end up finding what you were looking for?

Let me know.

Thanks,

-Jim
Last edited by jimm1909 on Wed Feb 11, 2015 12:48 am, edited 2 times in total.

michel.isard
Posts: 7
Joined: Mon Jan 03, 2011 8:45 pm
Humanity check: a real person
How many letters in "spam" (4)?: 3

Re: [Linux] Utility to Sort abc tunebook by tune name?

Postby michel.isard » Tue May 08, 2012 6:06 pm

The following script works on GVIM (linux and windows versions)

It sorts abc tunebook by title name, and renumbers X: fields

(no editing needed ... the script does the job !)

It can be used by a non GVIM user ( if something wrong, the commands to exit are : <escape>:q! )

See instructions in the script for usage.

Code: Select all

" Lauched in GVIM (LINUX or WINDOWS versions) this ex command outputs .abc file sorted by titles                                             
"                                                                                                                                           
" GVIM VERSION = 7.3                                                                                                                         
"                                                                                                                                           
" USAGE :                                                                                                                                   
"    - copy this file (under name "sort-titles.ex") and the .abc file to sort in an emply directory                                                                       
"    - open the .abc file in GVIM   (file/open ...)                                                                                                         
"    - GVIM opened, type :so sort-titles.ex  (or :so sort<tab>) <enter>                                                                     
"    - WAIT messages !                                                                                                                       
"          - message in black and white are OK                                                                                               
"          - if messages in color, errors in the output : don't use it                                                                       
"    - VIM processes the file, saves output, and quit                                                                                       
"    The outpout is : sorted_MyAbcFile.abc                                                                                                   
                                                                                                                                             
" SCRIPT :                                                                                                                                   
"    Rename "file" as "sorted_file                                                                                                           
:f sorted_%                                                                                                                                 
"    Remove empty lines                                                                                                                     
:g/^[ \t]*$/d                                                                                                                               
"    Add an empty line at the end of file                                                                                                   
$s,$,\r                                                                                                                                     
"    Add an empty line before X: fields                                                                                                     
:%s,^X:,\r&                                                                                                                                 
"    Put tag \n at the end of lines with text                                                                                               
:v/^$/s,$,\\n,                                                                                                                               
"    Join each tune in a single line                                                                                                         
:g/^X:/,/^$/j                                                                                                                               
":w! debug "    Put this line on step you want to check output                                                                               
"    Call VIM internal sort command                                                                                                         
"    An sorts on the _first_ T: field                                                                                                       
:1,$sort i /^[^T]*T:/                                                                                                                       
"    Reformat tunes on multiple lines                                                                                                       
:%s,\\n,\r,g                                                                                                                                 
:%s,^ *,,g                                                                                                                                   
"    Renumber X: fields (to disable this function, put a " at the beginning on the following line                                           
:let   i=1 | g/^X:/s/[0-9]*$/\=i/ |let i=i+1                                                                                                 
":let   i=10000001 | g/^X:/s/[0-9]*$/\=i/ |let i=i+1                                                                                         
"    Save Renamed file and quit                                                                                                             
:wq!                                                                                                                                         
                                                                                                                                             
" COMMENTS :                                                                                                                                 
" In Others Words, we :                                                                                                                     
" -  put each tune on a signe line                                                                                                           
" -  sort the file vith VIM internal sort fonction (/^.*T:/ skips text before title)                                                         
" -  reformat the tunes in their usual format                                                                                               
                                                                                                                                             
"WARNING !!! ALL THE FREE TEXT _AROUND_ THE TUNES IF REMOVED ! (see sample file and output)                                                 
"            * ALWAYS KEEP A COPY OF THE ORIGINAL FILE ; DO NOT ERASE IT * !!!                                                               
"                                                                                                                                           
"Licence : the same as GVIM


P.S. : As I was unable to save the code window in a file with correct end of lines, there are the commands without comments :

"
:f sorted_%
:g/^[ \t]*$/d
$s,$,\r
:%s,^X:,\r&
:v/^$/s,$,\\n,
:g/^X:/,/^$/j
:1,$sort i /^[^T]*T:/
:%s,\\n,\r,g
:%s,^ *,,g
:let i=1 | g/^X:/s/[0-9]*$/\=i/ |let i=i+1
:wq!
"

for copying with mouse and paste in "sort-titles.ex" text file

Regards, Michel

swera
Posts: 1
Joined: Wed Oct 29, 2014 8:10 pm
Humanity check: a real person
How many letters in "spam" (4)?: 4

Re: [Linux] Utility to Sort abc tunebook by tune name?

Postby swera » Wed Oct 29, 2014 8:18 pm

I just released a new version of aABC which finally has searching incorporated.

It's version 0.2.6 and should be pushing out shortly.

Hope it's useful.
swera


Return to “Software”

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest

cron