{"id":42,"date":"2009-09-29T19:08:21","date_gmt":"2009-09-29T17:08:21","guid":{"rendered":"http:\/\/tom.paschenda.org\/blog\/?p=42"},"modified":"2009-09-29T19:09:10","modified_gmt":"2009-09-29T17:09:10","slug":"splitting-mp3-files-using-mp3splt-and-batch-files","status":"publish","type":"post","link":"https:\/\/tom.paschenda.org\/blog\/?p=42","title":{"rendered":"Splitting mp3-files using mp3splt and batch files"},"content":{"rendered":"<p>\u2014\u2014RANT MODE: ON\u2014\u2013<\/p>\n<p>Back in the good old times of audio tapes, the concept of a track was not built into the system. This had pros and cons: It was quite easy to fast-forward or rewind to a certain position in a song or radio play. However, you could not just skip a track or forward to the next track, since a tape does not support tracks. (Actually, on some fancy tape decks, there was a button for that. Those things had a silence-detection built in and hence knew when a track ended and a new one began).<br \/>\nToday the situation is reversed: You can easily navigate backward and forward between tracks, but navigating within them is cumbersome or impossible on most cheap mp3 players (such as the ones I happen to possess).<br \/>\nAnother disadvantage of that cheap players is that they only remember the track, that was played when they were turned off, but not the position within the track. Since some audiobooks and podcasts come in rather long tracks, this is a pain in the ass as you spent quite some time fast-forwarding and rewinding through the track while you are hammering your brain trying to remember where you left off. And don&#8217;t you dare to let your finger tremble just the smallest bit on the fast-forward button, since on most players this means &#8220;next track&#8221; and you will have to start over. Argh!<\/p>\n<p>\u2014\u2014RANT MODE: OFF\u2014\u2013<\/p>\n<p>So, sometimes I have the need to split large mp3-files into smaller ones. In audiobooks and podcasts, it is most convenient to split the files at &#8216;silence positions&#8217; i.e. when no one is talking. There is a very nice tool that can do the job for you: It&#8217;s called mp3splt and you can get it here:<\/p>\n<p><a href=\"http:\/\/mp3splt.sourceforge.net\" title=\"mp3splt\" target=\"_blank\">http:\/\/mp3splt.sourceforge.net<\/a><\/p>\n<p>It&#8217;s a command line tool, but you can also download a GTK-frontend. mp3splt can search for silence positions within an mp3 file and then let it split the file at just those positions &#8211; neat! And just a few clicks.<\/p>\n<p>But wait: I have quite a number of podcasts (e.g. many episodes of <a href=\"http:\/\/www.se-radio.net\/\" target=\"_blank\">se-radio<\/a>). And &#8216;quite a number&#8217; times &#8216;a few clicks&#8217; is definitely too much boring work. But thou shall not worry: mp3splt is a command line tool, and hence can be used from within batch files.<\/p>\n<p><strong>Splitting a Single File<\/strong><\/p>\n<p>The following batch file splits a given file (&#8216;example.mp3&#8217;) into smaller files at all silence positions that are longer than 2 seconds and stores the resulting files in a folder that is named like the file, but without the extension (&#8216;example&#8217;).<br \/>\n<code><br \/>\nREM splitfile.bat<br \/>\nmp3splt -s -p min=2 -d \"%~n1\" %1<br \/>\n<\/code><\/p>\n<p><strong>Splitting all Files in a Directory<\/strong><\/p>\n<p>The following batch file calls the first file for all mp3s in the current directory:<br \/>\n<code><br \/>\nREM splitdir.bat<br \/>\nfor \/f \"tokens=*\" %%a IN ('dir \/b *.mp3') do call splitfile.bat \"%%a\"<br \/>\n<\/code><\/p>\n<p>Yay, works! (Even if there are blanks in the file names.)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u2014\u2014RANT MODE: ON\u2014\u2013 Back in the good old times of audio tapes, the concept of a track was not built into the system. This had pros and cons: It was quite easy to fast-forward or rewind to a certain position in a song or radio play. However, you could not just skip a track or [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-42","post","type-post","status-publish","format-standard","hentry","category-windows-batch-programming"],"_links":{"self":[{"href":"https:\/\/tom.paschenda.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/42","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tom.paschenda.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tom.paschenda.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tom.paschenda.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tom.paschenda.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=42"}],"version-history":[{"count":0,"href":"https:\/\/tom.paschenda.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/42\/revisions"}],"wp:attachment":[{"href":"https:\/\/tom.paschenda.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=42"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tom.paschenda.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=42"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tom.paschenda.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=42"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}