Mailing List Archive
tlug.jp Mailing List tlug archive tlug Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]Re: [tlug] "How to"
- Date: Mon, 12 May 2014 12:47:39 -0500
- From: "Daniel A. Ramaley" <daniel.ramaley@example.com>
- Subject: Re: [tlug] "How to"
- References: <CAJA1Y2bTWLWhb0tcuZyeJQDXtAXsGRdyUw_T_Ft7sZ_W6nXhLQ@mail.gmail.com>
- Organization: Drake University
- User-agent: KMail/4.12.4 (Linux/3.13-1-amd64; KDE/4.12.4; x86_64; ; )
On 2014-05-11 at 18:02:33 Bruno Raoult wrote: > 3- How would you *copy* your mp3 (real files) playlists from an m3u > file to another place, with no subtree in destination? Example: > src/a/b/c/d.mp3 => dst/a-b-c-d.mp3. m3u is a common file format for > music playing lists. I'd do something like this, where "file.m3u" is your m3u file: cat file.m3u | while read SRC ; do DST=$(echo "${SRC}" | sed -e 's/^src\///; s/\//-/g; s/^/dst\//') echo "Copying '${SRC}' to '${DST}'" cp -p "${SRC}" "${DST}" done If you want to get fancy you can get rid of the "useless use of cat", but i find that it makes the logic easier to understand. You could also optimize the sed more; i think 's/\//-/g; s/^src-/dst\//;' would also work as well and only require 2 substitutions. I put the echo in there so for testing you can just remove the cp and make sure it is calculating the source and destination paths correctly. > 4- If you consider the final target being /a/b/c/d, how would you > create the new m3u file from the original one? Example: you answered > question 3, but the target is for another device/machine, therefore > different path. I'm not sure i understand the question, but if you want to mangle the paths of each line in the m3u, one solution might involve passing the file through sed with the appropriate substitution commands. And if sed isn't powerful enough, i usually mangle things with "perl -ne" and a suitable 1-line script. __ Daniel A. Ramaley Network Engineer 2 Dial Center 122, Drake University 2407 Carpenter Ave / Des Moines IA 50311 USA Tel: +1 515 271-4540 Fax: +1 515 271-1938 E-mail: daniel.ramaley@example.com
- References:
- [tlug] "How to"
- From: Bruno Raoult
Home | Main Index | Thread Index
- Prev by Date: Re: [tlug] Living on the command line...
- Next by Date: Re: [tlug] "How to"
- Previous by thread: Re: [tlug] "How to"
- Next by thread: Re: [tlug] "How to"
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links