One possible way would be using tags. The basic idea is very simple: you can give tags to parts of the music and then you can choose which tags to keep.
A very basic example would look like this:
music = {
c8 d e f g a b c | \tag #'breaks { \break }
c b a g f e d c | \tag #'breaks { \pageBreak }
}
Both breaks are tagged with the tag #'breaks
. Now, in your parts, you would just use \new Staff \new Voice \music
(all tagged stuff is kept by default), while in the full score, you would use \new Staff \new Voice \removeWithTag #'breaks \music
(everything that has the tag #'music
is removed from there).
In your case, you could use some mass search-and-replace facility (I would use sed
on Linux but you will probably want something different) to replace each \break
with \tag #'breaks { \break }
, and similarly for \pageBreak
. I'm not sure if that's the best solution, but it will at least work.
And, by the way, if you want to make multiple scores out of one variable, tags are bit of a must. For instance, I needed to write a couple of guitar scores with tablature, and I of course wanted Lilypond to generate the tablature and engrave the score according to the same music, but often there need to be little tweaks for score and other little tweaks for tablature. So I'd use two tags, #'score
and #'tab
, to mark those tweaks, and then I'd use \keepWithTag #'score \someMusic
and \keepWithTag #'tab \someMusic
respectively.