10.4: Move lyrics from Sing that iTunes to pearLyrics
Dec 05, '05 06:40:00AM • Contributed by: Andrew Fletcher
Dec 05, '05 06:40:00AM • Contributed by: Andrew Fletcher
I used to use the Sing that iTune! widget to insert lyrics into iTunes, but moved to using pearLyrics to avoid a bug. (The bug was that occasionally the lyrics for one song would be put into the iTunes lyrics for a different song).
However, Sing that iTune! also saves lyrics as text files, but names them differently from pearLyrics. So I wrote a UNIX shell script to copy the files and rename them in pearLyrics format. This allows all the lyrics files to be kept together the same way. I thought someone who is learning about shell scripts might want to see it.
The script is:
#
# copy all "Sing that iTune!" song files to a directory with
# the song filename in pearLyrics format
#
# a directory called sing2pearfiles is created on the desktop
# to hold the output files, if required.
#
mkdir -p ~/Desktop/sing2pearfiles;
cd ~/Documents/Sing that iTune!/
find . -type f -name *.txt -exec sh -c 'oldname="{}"; newname=$(echo "${oldname#./}" | tr "[:upper:]" "[:lower:]" | tr "/" " "); cp "$oldname" ~/Desktop/sing2pearfiles/"$newname"' ;
To use it, paste it into a file and open a Terminal. Then run sh filename. This will create a folder called sing2pearfiles on your desktop. Use the Finder to move the files in that folder to where pearLyrics stores your files (on my Mac, it's ~/Library -> Application Support -> pearLyrics -> lyrics). The Sing that iTunes! files are not removed, so you may want to tidy them yourself.
The script works like this...
Firstly the sing2pearfiles folder is created if it doesn't already exist.mkdir -p ~/Desktop/sing2pearfiles
Then the "Sing that iTune!" lyrics folder is searched for files with names that end with ".txt" using.cd ~/Documents/Sing that iTune!/ find . -type f -name *.txt
For each of the files a shell script is run.-exec sh -c
The names of these files are manipulated to remove "./" from the start.oldname="{}"; newname=$(echo "${oldname#./}"
Any uppercase letters are turned into lowercase.tr "[:upper:]" "[:lower:]"
The directory separator character "/" is turned into a space.tr "/" " "
Finally the file is copied.cp "$oldname" ~/Desktop/sing2pearfiles/"$newname"'
[robg adds: I haven't tested this one...]
•
[14,619 views]
