take text, replace carriage returns, and turn into a string?


I have various scripts that I use to import and export iTunes info to MySQL. This lets me keep metadata between libraries and if I delete and re-add tracks.

I was trying to export the lyrics field to SQL (thru a shell script). Since the lyrics has paragraphs and carriage returns, it seems I need to turn the lyrics into a string without the CRs before I can export it. I’m having trouble doing that. I’ve tried searching and replacing CRs without success. Maybe someone can offer some help?


I found a partial answer in this thread.


Though I’m not sure exactly how to convert the string back to one that includes carriage returns. I can do a search and replace with \n; it works but seems a hack and not so elegant.


Hi Gary,

just yesterday there was a thread about this topic


hope it helps


It did help and I figured everything out. Thank you very much.

Whenever I delete iTunes tracks and reimport the CD later, it was a pain to redo the track lyrics. Now it’s all good.