newbie need to rename lots of files

newbie need to rename lots of files

Post by Aaro » Fri, 26 Dec 2003 07:22:01



Hi,
I am new to the list and need some help writing a script.

I am writing music notation for a book.
I have files which I am converting from Finale (binary format) into
lilypond (ascii).
The finale files have names such as 355.mus. I have converted the files
to musicxml and have a converter from musicxml2ly.

but the names are dreadful.

I need a way of taking these files and batch converting them  from
musicxml to lilypond.

Then I need to rename each file, by using the first few lines of the
notatation as its name as follows:
the directory
/ly/

has in it files 345.ly, 355.ly etc etc.

I want to make the file name from
from these lines in the file below (and all files in the directory)
e8 g8 |
b4 b8. b16 b8. a16 |
b4 a4 a8 e8 |
---------------------------------------------
so that the name will become: e8g8b4b8.b16b8.a16b4a4a8e8.ly
----------------------------------------------
this is an example file the notation starts on line 5.

1  POne = \notes {
2  s4 s4  \key e \minor
3  \time 3/4
4  \clef violin
5  e8 g8 |
6  b4 b8. b16 b8. a16 |
7  b4 a4 a8 e8 |
8  a4 a4 g8. e16 |
9
10  % Bar 5
11  g2 e8 g8 |
12  b4 b4 b8 a8 |
13  b4 a4 d8 e8 |
14  d8 c8 b8 a8 g8. fis16 |
15  e2 e g8 |

What do I use to take lines 5-7 remove unneeded charactors ( | spaces ~
\grace etc.) and then substitute this new name for a directory of files??

Can this be done with a bash script?
If so how?

Any ideas??
Thanks
Aaron

 
 
 

newbie need to rename lots of files

Post by Chris F.A. Johnso » Fri, 26 Dec 2003 08:31:37



> Hi,
> I am new to the list and need some help writing a script.

> I am writing music notation for a book.
> I have files which I am converting from Finale (binary format) into
> lilypond (ascii).
> The finale files have names such as 355.mus. I have converted the files
> to musicxml and have a converter from musicxml2ly.

> but the names are dreadful.

> I need a way of taking these files and batch converting them  from
> musicxml to lilypond.

> Then I need to rename each file, by using the first few lines of the
> notatation as its name as follows:
> the directory
> /ly/

> has in it files 345.ly, 355.ly etc etc.

> I want to make the file name from
> from these lines in the file below (and all files in the directory)
> e8 g8 |
> b4 b8. b16 b8. a16 |
> b4 a4 a8 e8 |
> ---------------------------------------------
> so that the name will become: e8g8b4b8.b16b8.a16b4a4a8e8.ly
> ----------------------------------------------
> this is an example file the notation starts on line 5.

> 1  POne = \notes {
> 2  s4 s4  \key e \minor
> 3  \time 3/4
> 4  \clef violin
> 5  e8 g8 |
> 6  b4 b8. b16 b8. a16 |
> 7  b4 a4 a8 e8 |
> 8  a4 a4 g8. e16 |
> 9
> 10  % Bar 5
> 11  g2 e8 g8 |
> 12  b4 b4 b8 a8 |
> 13  b4 a4 d8 e8 |
> 14  d8 c8 b8 a8 g8. fis16 |
> 15  e2 e g8 |

> What do I use to take lines 5-7 remove unneeded charactors ( | spaces ~
> \grace etc.) and then substitute this new name for a directory of files??

> Can this be done with a bash script?
> If so how?

   Are those line numbers part of the file?

cd DIRECTORY_WITH_FILES
x='[!a-g0-9.]'
for file in *.ly
do
  {
      read; read; read; read; ## discard first 4 lines
      read num notes   ## leave out num if lines are not numbered
      read num notes2
      read num notes3
  } < "$file"
 newfile=${notes//$x/}${notes2//$x/}${notes3//$x/}.ly
 mv "$file" "$newfile"
done

--
    Chris F.A. Johnson                        http://cfaj.freeshell.org
    ===================================================================
    My code (if any) in this post is copyright 2003, Chris F.A. Johnson
    and may be copied under the terms of the GNU General Public License

 
 
 

newbie need to rename lots of files

Post by Aaro » Fri, 26 Dec 2003 10:03:56


Thanks its 3am here so I will give it a whirl later and let you know.

Thanks again
Aaron

Quote:>>b4 b8. b16 b8. a16 |
>>b4 a4 a8 e8 |
>>---------------------------------------------
>>so that the name will become: e8g8b4b8.b16b8.a16b4a4a8e8.ly
>>----------------------------------------------
>>this is an example file the notation starts on line 5.

>>1  POne = \notes {
>>2  s4 s4  \key e \minor
>>3  \time 3/4
>>4  \clef violin
>>5  e8 g8 |
>>6  b4 b8. b16 b8. a16 |
>>7  b4 a4 a8 e8 |
>>8  a4 a4 g8. e16 |
>>9
>>10  % Bar 5
>>11  g2 e8 g8 |
>>12  b4 b4 b8 a8 |
>>13  b4 a4 d8 e8 |
>>14  d8 c8 b8 a8 g8. fis16 |
>>15  e2 e g8 |

>>What do I use to take lines 5-7 remove unneeded charactors ( | spaces ~
>>\grace etc.) and then substitute this new name for a directory of files??

>>Can this be done with a bash script?
>>If so how?

>    Are those line numbers part of the file?

No just to make the email easier to read

- Show quoted text -

Quote:

> cd DIRECTORY_WITH_FILES
> x='[!a-g0-9.]'
> for file in *.ly
> do
>   {
>       read; read; read; read; ## discard first 4 lines
>       read num notes   ## leave out num if lines are not numbered
>       read num notes2
>       read num notes3
>   } < "$file"
>  newfile=${notes//$x/}${notes2//$x/}${notes3//$x/}.ly
>  mv "$file" "$newfile"
> done

 
 
 

newbie need to rename lots of files

Post by Aaro » Mon, 29 Dec 2003 02:00:34


Thanks
  that really did the trick.

Someone suggested i use tr is that a good idea, it seemed most confusing
to me.
Thanks again
Aaron



>>Hi,
>>I am new to the list and need some help writing a script.

>>I am writing music notation for a book.
>>I have files which I am converting from Finale (binary format) into
>>lilypond (ascii).
>>The finale files have names such as 355.mus. I have converted the files
>>to musicxml and have a converter from musicxml2ly.

>>but the names are dreadful.

>>I need a way of taking these files and batch converting them  from
>>musicxml to lilypond.

>>Then I need to rename each file, by using the first few lines of the
>>notatation as its name as follows:
>>the directory
>>/ly/

>>has in it files 345.ly, 355.ly etc etc.

>>I want to make the file name from
>>from these lines in the file below (and all files in the directory)
>>e8 g8 |
>>b4 b8. b16 b8. a16 |
>>b4 a4 a8 e8 |
>>---------------------------------------------
>>so that the name will become: e8g8b4b8.b16b8.a16b4a4a8e8.ly
>>----------------------------------------------
>>this is an example file the notation starts on line 5.

>>1  POne = \notes {
>>2  s4 s4  \key e \minor
>>3  \time 3/4
>>4  \clef violin
>>5  e8 g8 |
>>6  b4 b8. b16 b8. a16 |
>>7  b4 a4 a8 e8 |
>>8  a4 a4 g8. e16 |
>>9
>>10  % Bar 5
>>11  g2 e8 g8 |
>>12  b4 b4 b8 a8 |
>>13  b4 a4 d8 e8 |
>>14  d8 c8 b8 a8 g8. fis16 |
>>15  e2 e g8 |

>>What do I use to take lines 5-7 remove unneeded charactors ( | spaces ~
>>\grace etc.) and then substitute this new name for a directory of files??

>>Can this be done with a bash script?
>>If so how?

>    Are those line numbers part of the file?

> cd DIRECTORY_WITH_FILES
> x='[!a-g0-9.]'
> for file in *.ly
> do
>   {
>       read; read; read; read; ## discard first 4 lines
>       read num notes   ## leave out num if lines are not numbered
>       read num notes2
>       read num notes3
>   } < "$file"
>  newfile=${notes//$x/}${notes2//$x/}${notes3//$x/}.ly
>  mv "$file" "$newfile"
> done

 
 
 

1. renaming lots of files

Hi.

I need to rename lots of files in one of my directories.   I would like
to move all the files ending in .f to .F
I tried futilely to do
mv *.f *.F
but it doesn't work.  I am working on a Linux system, but I don't think
that is what is causing the "problem" - I probably just don't have the
right command.   Is there a way to move multiple files like this?   What
command would I have to type?

Thanks for your help.

2. upgraded to gcc-2.6.3 - can't build kernel 1.2.9

3. Diamond stealth 3D 2000 X config

4. Renaming lots of files

5. This Is Badass!!!!!!

6. How to rename a lot of files into lower case?

7. CALL FOR PAPERS for the O'REILLY OPEN SOURCE CONVENTION 2000

8. Renaming a lot of similarly named files

9. How to rename a lot of files ?

10. Renaming lots of files

11. Help using awk and bash script to copy and rename lots of index.htm files

12. NEWBIE : rename files in directory