lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A quick way to change 50 lilypond files


From: rob canning
Subject: Re: A quick way to change 50 lilypond files
Date: Tue, 21 Dec 2010 10:15:00 +0000
User-agent: Thunderbird 2.0.0.24 (X11/20101027)

hsweet wrote:
Search/Replace in an editor is fine for one or 2 files. + I never remember
regex syntax so this way it's written down : ) +I just wanted to avoid
having to do this manually for >50 files. This does them all at once.  50 or
500.
i find sed handy for this kind of batch text manipulation

you have to escape the \ in \transpose so it is written \\transpose

you also have to do a bit of uglyness to escape the ' so ' will become \'\''

this oneliner will replace \transpose c' d' with \transpose c' b' in all the files in whatever directory you execute it in

sed s'/\\transpose c\'\'' d\'\'' /\\transpose c\'\'' b\'\''/'g *.ly

this will spit the output into the terminal for you to check then when you are sure it is good you can add the -i flag to make it actually edit the files

sed -i s'/\\transpose c\'\'' d\'\'' /\\transpose c\'\'' b\'\''/'g *.ly


rob

Here is one I just  thought of... (Haven't tested yet) It should make copies
transposed for clarinet.
$line=~s:\\relative c':\\transpose c b \\relative c':;
$line=~s:\\chordmode:\\transpose c b \ \chordmode:;
$line=~s:Violin:Clarinet:;



hsweet wrote:
I had a bunch of band charts I needed to update.  I wanted to assign each
chart a number and give them all a midi tempo. Then every now and then I
learn something new that I want to add.
 I dusted off an old Perl script, changed a few lines and I was able to
automate the process. It reads all the lilypond files in a folder, reads
and changes the text inside and writes the updated file to a temporary
folder called "changed".  Open to the changed folder in a terminal, type
"lilypond *" and lily will recompile everything.
The key to the whole thing is the line=~s/xxx /yyy /  lines.  If you have
ever used regex it will make sense.

open(OUT, ">changed/$file");       #output is to a folder called "Changed" one
level deeper in tree

                        foreach my $line(@text){

                                $line=~s:\\date:\\italic{ \"Sheet $cnt | Updated 
\" \\date } :;

                                $line=~s:\\midi { }:$midistring:;               
        

                            print OUT $line;

                }

This is the whole program.  http://old.nabble.com/file/p30495491/lymod.pl
lymod.pl





reply via email to

[Prev in Thread] Current Thread [Next in Thread]