![将音乐文件列表转换为播放列表的最简单方法是什么](https://linux22.com/image/1382998/%E5%B0%86%E9%9F%B3%E4%B9%90%E6%96%87%E4%BB%B6%E5%88%97%E8%A1%A8%E8%BD%AC%E6%8D%A2%E4%B8%BA%E6%92%AD%E6%94%BE%E5%88%97%E8%A1%A8%E7%9A%84%E6%9C%80%E7%AE%80%E5%8D%95%E6%96%B9%E6%B3%95%E6%98%AF%E4%BB%80%E4%B9%88.png)
我最近从 Windows 切换到 Linux,而我在 Windows 中使用的播放器将 flac 文件的评级存储在 id3v2 文件中,而我首选的 Linux 媒体播放器 clementine 无法读取该文件。我想创建一个大型播放列表,格式为 m3u、xspf、pls、asx、asx/ini、cue,我可以导入这些格式并手动设置评级(批量)。我拥有的文件是查找音乐文件的结果,其中 grep 在文件中找到“rating=x”或“Rating.x”。
ETA:输入文本文件如下所示:
./The Future Sound of London/The Isness/11 - Meadows.flac
./The Velvet Underground/The Velvet Underground/04 - Pale Blue Eyes.flac
./The Velvet Underground/The Velvet Underground/09 - The Murder Mystery.flac
./The Velvet Underground/The Velvet Underground/10 - After Hours.flac
./Sheryl Crow/C'mon, C'mon/02 - Soak Up The Sun.flac
./Sheryl Crow/Tuesday Night Music Club/11 - I Shall Believe.flac
./Sheryl Crow/Tuesday Night Music Club/07 - No One Said It Would Be Easy.flac
答案1
您只需将以下行添加到文件顶部(并赋予其 .m3u 扩展名)即可将这种相对路径转换为 m3u 播放列表。
#EXTM3U
作为参考,这是新文件的前几行。
#EXTM3U
./Plain White T's/Every Second Counts/13 - Hey There Delilah.flac
./The Police/Every Breath You Take- The Singles/07 - Every Little Thing She Does Is Magic.flac
./The Police/Every Breath You Take- The Singles/10 - Every Breath You Take.flac
./The Police/Every Breath You Take- The Singles/11 - King Of Pain.flac
./Roger Waters/Amused to Death/11 - Watching TV.flac
为了将来参考,您可以从命令行运行以下命令来生成带有“rating=1”或类似标签的播放列表。
for i in {1..5}; do printf "#EXTM3U\n" > ${i}star.m3u; find . -type f -exec grep -i -l --text "rating.$i" '{}' \; >> ${i}star.m3u; done