What is proper way to specify relative path to file in M3U playlists? [closed]

岁酱吖の 提交于 2019-12-21 13:26:08

问题


What is proper way to specify the path to mp3 file in M3U playlists, for use playlists in hardware players, like Compact & Shelf Stereos, Micro Component Systems, Car Audio Players? I understand the path should be relative, for more reliable playback. For example, Windows Media Player m3u playlist have two dots before the leading back slash:

#EXTM3U
#EXTINF:0,Artist - Track Name (Mix).mp3
..\My Album\Artist - Track Name (Mix).mp3

Does this dots and leading back slashes make any sense for hardware players?


回答1:


All the players I've seen (Windows Media Player included) accept relative paths.

The .. means one directory up. If you wanted to specify the current path, either use ., or don't specify it at all.

If you have compatibility problems, consider using regular "forward" slashes / instead. Most hardware players aren't running Windows, and most Windows software can handle the regular slashes even though Windows paths use backslashes \.




回答2:


Here is a one-line command to convert absolute to relative for an .m3u file (update playlistname and username before using):

name='playlistname'; cd /Volumes/'Mac Storage'/Music/Music/playlists; cat $name.m3u >> $name-old.m3u; LC_ALL=C sed -i '' 's/\\Users\\username\\Music\\/\.\.\//g' $name.m3u

What it means:

  • name='playlistname' - The name of the playlist.m3u file you wish to change.
  • cd ~/Music/playlists; - Navigates to the playlists folder.
  • cat playlist.m3u >> playlist-old.m3u; - Backs up your playlist before making changes.
  • sed -i '' 's/oldtext/newtext/g' playlist.m3u - In the target playlist, replaces all instances (g for global) of the oldtext (the absolute path) with newtext (the relative path: ../).
  • LC_ALL=C avoids an error that sometimes comes up: sed: RE error: illegal byte sequence.


来源:https://stackoverflow.com/questions/25676803/what-is-proper-way-to-specify-relative-path-to-file-in-m3u-playlists

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!