{"id":2241,"date":"2005-09-04T23:07:32","date_gmt":"2005-09-05T03:07:32","guid":{"rendered":"http:\/\/scruss.com\/blog\/?p=2241"},"modified":"2005-09-04T23:08:25","modified_gmt":"2005-09-05T03:08:25","slug":"batch-renaming-itunes-directories","status":"publish","type":"post","link":"https:\/\/scruss.com\/blog\/2005\/09\/04\/batch-renaming-itunes-directories\/","title":{"rendered":"batch renaming iTunes directories"},"content":{"rendered":"<p>In partial response to the Ask Metafilter question &#8220;<a href=\"http:\/\/ask.metafilter.com\/mefi\/22880\">How can I rename my music folders on my Mac based on ID3 tags?<\/a>&#8220;:<\/p>\n<pre>#!\/bin\/bash\r\n# itunes_sanity.sh - fix dir names created by iTunes\r\n# only works for mp3s, and not actually tested on a Mac\r\n# created by scruss on Sun Sep 4 22:05:00 EDT 2005\r\n\r\nfind \"$@\" -type d -mindepth 1 | while read directory\r\ndo\r\n  artistdir=$(dirname \"$directory\")\r\n  firstfile=$( find \"$directory\" -type f -iname '*.mp3' | head -n1 )\r\n  year=$( id3info \"$firstfile\" | egrep ' TYE ' | sed 's\/=== TYE (Year): \/\/; s\/[^0-9]*\/\/;' )\r\n  album=$( id3info \"$firstfile\" | egrep ' TAL ' | sed 's,=== TAL (Album\/Movie\/Show title): ,,;' )\r\n  echo mv \\'$directory\\' \\'$artistdir\/\\[$year\\] $album\\'\r\ndone\r\n<\/pre>\n<p>So if you were in the terminal, in your music library (one up from the individual artist directories), and you did:<\/p>\n<pre>itunes_sanity.sh Dan\\ Jones Tripping\\ Daisy<\/pre>\n<p>you&#8217;d get:<\/p>\n<pre>mv 'Dan Jones\/Get Sounds Now' 'Dan Jones\/[2005] Get Sounds Now'\r\nmv 'Dan Jones\/One Man Submarine' 'Dan Jones\/[2003] One Man Submarine'\r\nmv 'Tripping Daisy\/Jesus Hits Like the Atom Bomb' 'Tripping Daisy\/[1998] Jesus Hits Like the Atom Bomb'<\/pre>\n<p>If that looks okay, run the output through the shell:<\/p>\n<pre>itunes_sanity.sh Dan\\ Jones Tripping\\ Daisy | sh<\/pre>\n<p>and all should be well.<\/p>\n<p>You&#8217;ll need <a href=\"http:\/\/id3lib.sourceforge.net\/\">id3lib<\/a>, which is probably most easily installed from <a href=\"http:\/\/fink.sourceforge.net\/\">Fink<\/a>. Also, this only works for mp3 files; I can&#8217;t grok the tag info for AAC files. And finally, this might go seriously screwy on weird characters in filenames. You know my feelings on that&nbsp;&hellip;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In partial response to the Ask Metafilter question &#8220;How can I rename my music folders on my Mac based on ID3 tags?&#8220;: #!\/bin\/bash # itunes_sanity.sh &#8211; fix dir names created by iTunes # only works for mp3s, and not actually tested on a Mac # created by scruss on Sun Sep 4 22:05:00 EDT 2005 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[7],"tags":[1015,1340,1168,705,94,1477,1190,836,931,1066,650,104,150,114,269,313,566,45,47,166,1345,1335,1372,766,1177,762,212,486,1269],"class_list":["post-2241","post","type-post","status-publish","format-standard","hentry","category-computers-suck","tag-1015","tag-aac","tag-album","tag-art","tag-artist","tag-bash","tag-bomb","tag-dan","tag-director","tag-eat","tag-ink","tag-itunes","tag-led","tag-library","tag-mac","tag-metafilter","tag-movie","tag-mp3","tag-music","tag-old","tag-ren","tag-rip","tag-shell","tag-sound","tag-terminal","tag-test","tag-tories","tag-trip","tag-ugh"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pQNZZ-A9","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts\/2241","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/comments?post=2241"}],"version-history":[{"count":0,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts\/2241\/revisions"}],"wp:attachment":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/media?parent=2241"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/categories?post=2241"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/tags?post=2241"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}