Take the attachment as an inspiration - but without any warranty.
Too late to do it right, no time either.

It seems to work but hasn't been really tested.

The script has to be somewhere in the PATH (e.g. in ~/bin) and takes the directory from which it is called as the root to be searched.

cd ~/lily-root
lilypond-all.py

will (should) recursively walk through the lily-root directory and try to compile all .ly files it encounters.

HTH
Urs

Am 13.11.2014 22:46, schrieb Stefan Thomas:
Dear Urs,
Yes, a python script would be fine.

    Is a Python script an option?

    You can surely do what you want with a pure shell script, but
    Python may be cleaner to read?

    Best
    Urs

    Am 13.11.2014 22:06, schrieb Stefan Thomas:

    Dear Nick,
    thanks for Your reply.
    But Your command writes the pdf-files to the folder, where  it's
    executed.
    I want the pdf-files in the same folder as the ly-files.

        On 14/11/2014 06:39, Stefan Thomas wrote:

            Dear community,

            I would like to compile (on a Ubuntu-machine) all
            ly-files, including those, which are in subfolders.

            How can I do this?

        cd to the parent folder, and issue the following command:

        find . -name '*.ly' -exec lilypond {} \;




#!/usr/bin/env python
#-*- coding:utf-8 -*-

import os, subprocess

def recurse(dir):
    """Recurse in a directory and compile all LilyPond files"""
    os.chdir(dir)
    for item in os.listdir(dir):
        print "Enter directory", dir
        abs_item = os.path.join(dir, item)
        if os.path.isdir(abs_item):
        	   recurse(abs_item)
        else:
            file_name, ext = os.path.splitext(item)
            if ext == '.ly':
                print "Compile file", item
                pr = subprocess.Popen('lilypond ' + abs_item, cwd = dir, 
                              shell = True, 
                              stdout = subprocess.PIPE, 
                              stderr = subprocess.PIPE)
                (out, error) = pr.communicate()
                print out
                print error

def main():
    current_dir = os.getcwd()
    recurse(os.getcwd())
    
if __name__ == "__main__":
    main()
_______________________________________________
lilypond-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to