{"id":1865,"date":"2016-02-01T16:57:18","date_gmt":"2016-02-01T14:57:18","guid":{"rendered":"http:\/\/www.wittwer.nl\/?p=1865"},"modified":"2016-02-01T16:57:18","modified_gmt":"2016-02-01T14:57:18","slug":"playlists-in-pi-musicbox","status":"publish","type":"post","link":"https:\/\/www.wittwer.nl\/?p=1865","title":{"rendered":"Playlists in Pi Musicbox"},"content":{"rendered":"<p>Pi Musicbox has no built-in functionality for creating playlists for local music files that are located on the SD card or a USB drive. Playlists (m3u files) need to be located (by default at least, this can be changed in settings.ini) in <em>\/var\/lib\/mopidy\/playlists<\/em>. Filenames must be absolute of course. I started out by creating these playlists manually, but since they are simple text files, it can be done in a few lines of bash script:<\/p>\n<pre>#!\/bin\/bash\r\nrm -f \/var\/lib\/mopidy\/playlists\/\"$2\".m3u\r\nfor filename in \"$1\"\/*.mp3\r\ndo\r\n\u00a0\u00a0\u00a0 echo $filename &gt;&gt; \/var\/lib\/mopidy\/playlists\/\"$2.m3u\"\r\ndone<\/pre>\n<p>Save it in the root directory as <em>playlist.sh<\/em> and make it executable via <em>chmod a+x playlist.sh<\/em>. You can then run it via <em>.\/playlist.sh directory playlistname<\/em>, e.g. <em>.\/playlist.sh \/music\/USB\/Free Free<\/em>. It is important to supply the directory without trailing backslash.<\/p>\n<p>This works fine for adding playlists for one or two directories, but it still quite slow when adding them for a couple. In comes the following script, that automatically does the same thing for all subdirectories in a given directory (<strong>Caution: This deletes all existing m3u files<\/strong>):<\/p>\n<pre>#!\/bin\/bash\r\nrm -f \/var\/lib\/mopidy\/playlists\/*.m3u\r\nfind \"$1\" -type d |\r\nwhile read subdir\r\ndo\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 for filename in \"$subdir\"\/*.mp3\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 do\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if [ -e \"$filename\" ]\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 then\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 echo $filename &gt;&gt; \/var\/lib\/mopidy\/playlists\/\"${subdir##*\/}.m3u\"\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 fi\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 done\r\ndone<\/pre>\n<p>It is invoked, after saving to <em>playlists.sh<\/em> and <em>chmod a+x playlists.sh<\/em>, with <em>.\/playlists.sh \/music\/USB<\/em>, or wherever the MP3 files are located. Mopidy then needs to be restarted via <em>\/etc\/init.d\/mopidy restart<\/em> to make the playlists visible in the web interface.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Pi Musicbox has no built-in functionality for creating playlists for local music files that are located on the SD card or a USB drive. Playlists (m3u files) need to be located (by default at least, this can be changed in settings.ini) in \/var\/lib\/mopidy\/playlists. Filenames must be absolute of course. I started out by creating these [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1871,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[78],"tags":[87],"class_list":["post-1865","post","type-post","status-publish","format-standard","has-post-thumbnail","category-tech","tag-raspberry-pi","czr-hentry"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 4.9.9 - aioseo.com -->\n\t<meta name=\"description\" content=\"Pi Musicbox has no built-in functionality for creating playlists for local music files that are located on the SD card or a USB drive. Playlists (m3u files) need to be located (by default at least, this can be changed in settings.ini) in \/var\/lib\/mopidy\/playlists. Filenames must be absolute of course. I started out by creating these\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"admin\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/www.wittwer.nl\/?p=1865\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 4.9.9\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"wittwer.nl | The website of Tobias Wittwer\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Playlists in Pi Musicbox | wittwer.nl\" \/>\n\t\t<meta property=\"og:description\" content=\"Pi Musicbox has no built-in functionality for creating playlists for local music files that are located on the SD card or a USB drive. Playlists (m3u files) need to be located (by default at least, this can be changed in settings.ini) in \/var\/lib\/mopidy\/playlists. Filenames must be absolute of course. I started out by creating these\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/www.wittwer.nl\/?p=1865\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2016-02-01T14:57:18+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2016-02-01T14:57:18+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Playlists in Pi Musicbox | wittwer.nl\" \/>\n\t\t<meta name=\"twitter:description\" content=\"Pi Musicbox has no built-in functionality for creating playlists for local music files that are located on the SD card or a USB drive. Playlists (m3u files) need to be located (by default at least, this can be changed in settings.ini) in \/var\/lib\/mopidy\/playlists. Filenames must be absolute of course. I started out by creating these\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.wittwer.nl\\\/?p=1865#article\",\"name\":\"Playlists in Pi Musicbox | wittwer.nl\",\"headline\":\"Playlists in Pi Musicbox\",\"author\":{\"@id\":\"https:\\\/\\\/www.wittwer.nl\\\/?author=1#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/www.wittwer.nl\\\/#organization\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/www.wittwer.nl\\\/wp-content\\\/uploads\\\/2016\\\/01\\\/pmblogo.png\",\"width\":178,\"height\":174},\"datePublished\":\"2016-02-01T16:57:18+02:00\",\"dateModified\":\"2016-02-01T16:57:18+02:00\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.wittwer.nl\\\/?p=1865#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.wittwer.nl\\\/?p=1865#webpage\"},\"articleSection\":\"Technology, Raspberry Pi\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.wittwer.nl\\\/?p=1865#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.wittwer.nl#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.wittwer.nl\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.wittwer.nl\\\/?cat=78#listItem\",\"name\":\"Technology\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.wittwer.nl\\\/?cat=78#listItem\",\"position\":2,\"name\":\"Technology\",\"item\":\"https:\\\/\\\/www.wittwer.nl\\\/?cat=78\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.wittwer.nl\\\/?p=1865#listItem\",\"name\":\"Playlists in Pi Musicbox\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.wittwer.nl#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.wittwer.nl\\\/?p=1865#listItem\",\"position\":3,\"name\":\"Playlists in Pi Musicbox\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.wittwer.nl\\\/?cat=78#listItem\",\"name\":\"Technology\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.wittwer.nl\\\/#organization\",\"name\":\"wittwer.nl\",\"description\":\"The website of Tobias Wittwer\",\"url\":\"https:\\\/\\\/www.wittwer.nl\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.wittwer.nl\\\/?author=1#author\",\"url\":\"https:\\\/\\\/www.wittwer.nl\\\/?author=1\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/www.wittwer.nl\\\/?p=1865#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/1800dc31a7ae6c14fe15c96ab908125ce0c09dc3ad87f0dbaad05f7370c1eecb?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"admin\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.wittwer.nl\\\/?p=1865#webpage\",\"url\":\"https:\\\/\\\/www.wittwer.nl\\\/?p=1865\",\"name\":\"Playlists in Pi Musicbox | wittwer.nl\",\"description\":\"Pi Musicbox has no built-in functionality for creating playlists for local music files that are located on the SD card or a USB drive. Playlists (m3u files) need to be located (by default at least, this can be changed in settings.ini) in \\\/var\\\/lib\\\/mopidy\\\/playlists. Filenames must be absolute of course. I started out by creating these\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.wittwer.nl\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.wittwer.nl\\\/?p=1865#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/www.wittwer.nl\\\/?author=1#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/www.wittwer.nl\\\/?author=1#author\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/www.wittwer.nl\\\/wp-content\\\/uploads\\\/2016\\\/01\\\/pmblogo.png\",\"@id\":\"https:\\\/\\\/www.wittwer.nl\\\/?p=1865\\\/#mainImage\",\"width\":178,\"height\":174},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.wittwer.nl\\\/?p=1865#mainImage\"},\"datePublished\":\"2016-02-01T16:57:18+02:00\",\"dateModified\":\"2016-02-01T16:57:18+02:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.wittwer.nl\\\/#website\",\"url\":\"https:\\\/\\\/www.wittwer.nl\\\/\",\"name\":\"wittwer.nl\",\"description\":\"The website of Tobias Wittwer\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.wittwer.nl\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Playlists in Pi Musicbox | wittwer.nl","description":"Pi Musicbox has no built-in functionality for creating playlists for local music files that are located on the SD card or a USB drive. Playlists (m3u files) need to be located (by default at least, this can be changed in settings.ini) in \/var\/lib\/mopidy\/playlists. Filenames must be absolute of course. I started out by creating these","canonical_url":"https:\/\/www.wittwer.nl\/?p=1865","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.wittwer.nl\/?p=1865#article","name":"Playlists in Pi Musicbox | wittwer.nl","headline":"Playlists in Pi Musicbox","author":{"@id":"https:\/\/www.wittwer.nl\/?author=1#author"},"publisher":{"@id":"https:\/\/www.wittwer.nl\/#organization"},"image":{"@type":"ImageObject","url":"https:\/\/www.wittwer.nl\/wp-content\/uploads\/2016\/01\/pmblogo.png","width":178,"height":174},"datePublished":"2016-02-01T16:57:18+02:00","dateModified":"2016-02-01T16:57:18+02:00","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/www.wittwer.nl\/?p=1865#webpage"},"isPartOf":{"@id":"https:\/\/www.wittwer.nl\/?p=1865#webpage"},"articleSection":"Technology, Raspberry Pi"},{"@type":"BreadcrumbList","@id":"https:\/\/www.wittwer.nl\/?p=1865#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/www.wittwer.nl#listItem","position":1,"name":"Home","item":"https:\/\/www.wittwer.nl","nextItem":{"@type":"ListItem","@id":"https:\/\/www.wittwer.nl\/?cat=78#listItem","name":"Technology"}},{"@type":"ListItem","@id":"https:\/\/www.wittwer.nl\/?cat=78#listItem","position":2,"name":"Technology","item":"https:\/\/www.wittwer.nl\/?cat=78","nextItem":{"@type":"ListItem","@id":"https:\/\/www.wittwer.nl\/?p=1865#listItem","name":"Playlists in Pi Musicbox"},"previousItem":{"@type":"ListItem","@id":"https:\/\/www.wittwer.nl#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/www.wittwer.nl\/?p=1865#listItem","position":3,"name":"Playlists in Pi Musicbox","previousItem":{"@type":"ListItem","@id":"https:\/\/www.wittwer.nl\/?cat=78#listItem","name":"Technology"}}]},{"@type":"Organization","@id":"https:\/\/www.wittwer.nl\/#organization","name":"wittwer.nl","description":"The website of Tobias Wittwer","url":"https:\/\/www.wittwer.nl\/"},{"@type":"Person","@id":"https:\/\/www.wittwer.nl\/?author=1#author","url":"https:\/\/www.wittwer.nl\/?author=1","name":"admin","image":{"@type":"ImageObject","@id":"https:\/\/www.wittwer.nl\/?p=1865#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/1800dc31a7ae6c14fe15c96ab908125ce0c09dc3ad87f0dbaad05f7370c1eecb?s=96&d=mm&r=g","width":96,"height":96,"caption":"admin"}},{"@type":"WebPage","@id":"https:\/\/www.wittwer.nl\/?p=1865#webpage","url":"https:\/\/www.wittwer.nl\/?p=1865","name":"Playlists in Pi Musicbox | wittwer.nl","description":"Pi Musicbox has no built-in functionality for creating playlists for local music files that are located on the SD card or a USB drive. Playlists (m3u files) need to be located (by default at least, this can be changed in settings.ini) in \/var\/lib\/mopidy\/playlists. Filenames must be absolute of course. I started out by creating these","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/www.wittwer.nl\/#website"},"breadcrumb":{"@id":"https:\/\/www.wittwer.nl\/?p=1865#breadcrumblist"},"author":{"@id":"https:\/\/www.wittwer.nl\/?author=1#author"},"creator":{"@id":"https:\/\/www.wittwer.nl\/?author=1#author"},"image":{"@type":"ImageObject","url":"https:\/\/www.wittwer.nl\/wp-content\/uploads\/2016\/01\/pmblogo.png","@id":"https:\/\/www.wittwer.nl\/?p=1865\/#mainImage","width":178,"height":174},"primaryImageOfPage":{"@id":"https:\/\/www.wittwer.nl\/?p=1865#mainImage"},"datePublished":"2016-02-01T16:57:18+02:00","dateModified":"2016-02-01T16:57:18+02:00"},{"@type":"WebSite","@id":"https:\/\/www.wittwer.nl\/#website","url":"https:\/\/www.wittwer.nl\/","name":"wittwer.nl","description":"The website of Tobias Wittwer","inLanguage":"en-US","publisher":{"@id":"https:\/\/www.wittwer.nl\/#organization"}}]},"og:locale":"en_US","og:site_name":"wittwer.nl | The website of Tobias Wittwer","og:type":"article","og:title":"Playlists in Pi Musicbox | wittwer.nl","og:description":"Pi Musicbox has no built-in functionality for creating playlists for local music files that are located on the SD card or a USB drive. Playlists (m3u files) need to be located (by default at least, this can be changed in settings.ini) in \/var\/lib\/mopidy\/playlists. Filenames must be absolute of course. I started out by creating these","og:url":"https:\/\/www.wittwer.nl\/?p=1865","article:published_time":"2016-02-01T14:57:18+00:00","article:modified_time":"2016-02-01T14:57:18+00:00","twitter:card":"summary","twitter:title":"Playlists in Pi Musicbox | wittwer.nl","twitter:description":"Pi Musicbox has no built-in functionality for creating playlists for local music files that are located on the SD card or a USB drive. Playlists (m3u files) need to be located (by default at least, this can be changed in settings.ini) in \/var\/lib\/mopidy\/playlists. Filenames must be absolute of course. I started out by creating these"},"aioseo_meta_data":{"post_id":"1865","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[],"defaultGraph":"","defaultPostTypeGraph":""},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"breadcrumb_settings":null,"limit_modified_date":false,"ai":null,"created":"2020-12-23 13:03:43","updated":"2025-06-04 00:58:38","seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.wittwer.nl\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.wittwer.nl\/?cat=78\" title=\"Technology\">Technology<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tPlaylists in Pi Musicbox\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/www.wittwer.nl"},{"label":"Technology","link":"https:\/\/www.wittwer.nl\/?cat=78"},{"label":"Playlists in Pi Musicbox","link":"https:\/\/www.wittwer.nl\/?p=1865"}],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.wittwer.nl\/wp-content\/uploads\/2016\/01\/pmblogo.png","jetpack_shortlink":"https:\/\/wp.me\/plKIk-u5","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.wittwer.nl\/index.php?rest_route=\/wp\/v2\/posts\/1865","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wittwer.nl\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wittwer.nl\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wittwer.nl\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wittwer.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1865"}],"version-history":[{"count":3,"href":"https:\/\/www.wittwer.nl\/index.php?rest_route=\/wp\/v2\/posts\/1865\/revisions"}],"predecessor-version":[{"id":1870,"href":"https:\/\/www.wittwer.nl\/index.php?rest_route=\/wp\/v2\/posts\/1865\/revisions\/1870"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wittwer.nl\/index.php?rest_route=\/wp\/v2\/media\/1871"}],"wp:attachment":[{"href":"https:\/\/www.wittwer.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1865"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wittwer.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1865"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wittwer.nl\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1865"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}