I would like to open a text m3u file and add the same string to the beginning of each line. I think I am close, but I cannot figure out how to escape the ampersand in the following code:
gawk-3.1.6.exe "{print /var/media/Music2.0TB2.1USB/Audio Files/Music/Rock & Roll/ $0}" "L:\Music\Rock & Roll\Rock & Rated.m3u"
The ampersand is part of a folder name and shows up twice.
Many thanks
each line in this text file is a shortened pathname:
Pink Floyd\(1987-09-07) A Momentary Lapse of Reason\03. The Dogs Of War.flac
I want to add the full path to that file by concatenating two strings.
the rest of the path is:
/var/media/Music2.0TB2.1USB/Audio Files/Music/Rock & Roll/
output should be
/var/media/Music2.0TB2.1USB/Audio Files/Music/Rock & Roll/Pink Floyd\(1987-09-07) A Momentary Lapse of Reason\03. The Dogs Of War.flac
and I just noticed the slashes are different, easy to fix with global search and replace
Aia
May 6, 2017, 7:43pm
2
Perhaps ...
gawk '{print "/var/media/Music2.0TB2.1USB/Audio Files/Music/Rock & Roll/" $0}' example.m3u
Did you try single quotes on the gawk script section?:
gawk-3.1.6.exe '{print "/var/media/Music2.0TB2.1USB/Audio Files/Music/Rock & Roll/" $0}' "L:\Music\Rock & Roll\Rock & Rated.m3u"
aia - not sure. But space concatenates the $0, a comma will put a space in there which, if that first quoted section is some kind of filename might be a problem.
It doesn't like the single quote. It wants to execute Roll.
It says the single quote is an invalid character.
---------- Post updated at 04:54 PM ---------- Previous update was at 04:53 PM ----------
Yes, I am making a path name - no space wanted.
Aia
May 6, 2017, 7:52pm
7
I thought that the person wanted the space, until I realized that most likely wanted to craft a full path for each entry.
Aia
May 6, 2017, 8:08pm
8
That's a side effect of the Windows command line. I do not use Windows for doing Unix tasks, therefore I can not test a solution for you.
Maybe create an awk file.
cat display.awk
{print "/var/media/Music2.0TB2.1USB/Audio Files/Music/Rock & Roll/" $0}
Then, execute.
gawk -f display.awk example.m3u
Or some variation of the same.