P.S. If you add "-D search" right after the find command, i.e., as the
first option specified, find will output the paths it finds as it goes
(otherwise, there is no visible output and one must wait until the command
terminates and the prompt returns).

Also, if you have openlilylib in the same folder structure, using find in
this way will cause the reformat option to run on all of them, including
all the openlilylib files. I know because I just did this on my own
composition collection.

If you are satisfied with the reformat operations you can use find again to
remove all of the .ly~ files by changing the name part to "-iname \*.ly~\*"
and exec'ing "rm":

find ./* -type f -iname \*.ly~\* -exec rm -rf {} \;

It is helpful BEFORE doing this to run the find command without the -exec
to confirm visually what files the rm -rf will remove :-)

Regards
--

“Happiness is the meaning and the purpose of life, the whole aim and end of
human existence.”

― Aristotle


On Fri, Dec 18, 2020 at 11:32 AM Guy Stalnaker <jimmyg...@gmail.com> wrote:

> You may know this, but on the chance you do not ...
>
> Depending on your terminal shell (e.g. I use zsh), you can use the find
> command and its -exec option to find all .ly files in a folder hierarchy
> and run the command on them.
>
> #> find ./* -type f -iname \*.ly\* -exec [python.ly command here] {} \;
>
> ./* causes folder recursion
>
> -type f limits find to files
>
> -iname ignores case
>
> The {} substitutes for the file name.
>
> \; terminates the command executed.
>
> I've used this command syntax quite a bit. There are permutations for
> using find that involve piping to xargs without invoking -exec and using
> -print0 which are sometimes necessary (Google helps here).
>
> Regards
>
> On Fri, Dec 18, 2020, 10:30 AM Knute Snortum <ksnor...@gmail.com> wrote:
>
>> This is a great utility!  I like the ability to export syntax
>> highlighting to HTML.
>>
>> For changing a group of files, I would try:
>>
>>     ly --in-place reformat *.ly
>>
>> This will modify the files in place and give you a backup of the file
>> with the filename suffixed with a "~".
>>
>> --
>> Knute Snortum
>>
>>
>> --
>> Knute Snortum
>>
>>
>>
>> On Thu, Dec 17, 2020 at 1:28 PM David Menéndez Hurtado
>> <davidmen...@gmail.com> wrote:
>> >
>> >
>> >
>> > On Thu, 17 Dec 2020 at 21:59, Fr. Samuel Springuel <
>> rpspring...@gmail.com> wrote:
>> >>
>> >> I’ve developed a large collection of music files over several years
>> have recently noticed that there are some stylistic formatting deviations
>> in some of them and so I’m looking for a tool that will check all my files
>> for these problems (and ideally fix them).  I can do this in Frescobaldi
>> using Tools->Code Formatting->Format, but I’m looking for a command-line
>> option that I can use to fix my files en masse (and eventually incorporate
>> into a check-in hook on my git repositories to prevent this from happening
>> again).  Does anyone have any suggestions for how to pull this off?
>> >
>> >
>> >
>> > pip install python-ly
>> > ly "reformat" input.ly > output.ly
>> >
>> > That runs exactly the same that Frescobaldi does. More documentation:
>> https://pypi.org/project/python-ly/
>> >
>> > I found it poking around the Frescobaldi source, found something called
>> reformat
>> >
>> https://github.com/frescobaldi/frescobaldi/blob/f01cdbe2baee93f3ab361647a42885a1cfab6b40/frescobaldi_app/reformat.py#L46
>> >
>> > That calls ly.reformat.reformat
>> >
>> https://github.com/frescobaldi/python-ly/blob/master/ly/reformat.py#L102
>> >
>> >
>> > /David.
>> >
>>
>>

Reply via email to