
{"id":179,"date":"2016-01-16T02:39:53","date_gmt":"2016-01-16T01:39:53","guid":{"rendered":"https:\/\/www.munerotto.it\/?p=179"},"modified":"2016-10-20T01:54:27","modified_gmt":"2016-10-20T00:54:27","slug":"maildir-to-mailbox","status":"publish","type":"post","link":"https:\/\/www.munerotto.it\/?p=179","title":{"rendered":"Maildir to Mailbox"},"content":{"rendered":"<p>This is ok for every mdir to mbox conversion but it specially suited if you move from the evolution mail client to the thunderbird one.<\/p>\n<figure id=\"attachment_181\" aria-describedby=\"caption-attachment-181\" style=\"width: 300px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/www.munerotto.it\/maildir-to-mailbox\/evo-mdie-2-mbox\/\" rel=\"attachment wp-att-181\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-181\" src=\"https:\/\/www.munerotto.it\/wp-content\/uploads\/2016\/01\/evo-mdie-2-mbox-300x175.jpg\" alt=\"Mdir 2 mbox\" width=\"300\" height=\"175\" srcset=\"https:\/\/www.munerotto.it\/wp-content\/uploads\/2016\/01\/evo-mdie-2-mbox-300x175.jpg 300w, https:\/\/www.munerotto.it\/wp-content\/uploads\/2016\/01\/evo-mdie-2-mbox.jpg 435w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-181\" class=\"wp-caption-text\">Mdir 2 mbox<\/figcaption><\/figure>\n<h1 class=\"western\">STEP 0<\/h1>\n<p>&nbsp;<\/p>\n<p>a) retrieve required util from<\/p>\n<p><a href=\"https:\/\/github.com\/jooooooon\/maildir2mbox\">https:\/\/github.com\/jooooooon\/maildir2mbox<\/a><\/p>\n<p><!--more--><\/p>\n<p>(Also the perl helper file as in the instruction)<\/p>\n<p>This perl script works for just a folder: if you have just one your done. I have many so I wrote a wrap for that script that automatically iterates from the folders with the intent to avoid manual working.<\/p>\n<p>&nbsp;<\/p>\n<p>b.1) fix perl<\/p>\n<p>(from <a href=\"http:\/\/www.livejournal.com\/doc\/server\/lj.install.perl_setup.modules.html\">http:\/\/www.livejournal.com\/doc\/server\/lj.install.perl_setup.modules.html<\/a> )<\/p>\n<p>From the root prompt on your server, invoke the CPAN shell:<\/p>\n<blockquote>\n<p class=\"comandi-cli-western\"># perl -MCPAN -e shell<\/p>\n<\/blockquote>\n<p>Once the Perl interpreter has loaded (and been configured), you can install modules with: install MODULENAME.<\/p>\n<p>The first thing you should do is upgrade your CPAN:<\/p>\n<blockquote>\n<p class=\"comandi-cli-western\">cpan&gt; install Bundle::CPAN<\/p>\n<\/blockquote>\n<p>Once it is completed, type:<\/p>\n<blockquote>\n<p class=\"comandi-cli-western\">cpan&gt; reload cpan<\/p>\n<\/blockquote>\n<p>Now, enter the following command to retrieve the required modules:<\/p>\n<blockquote>\n<p class=\"comandi-cli-western\">CPAN&gt; install DateTime::Format::Mail<\/p>\n<\/blockquote>\n<p>&nbsp;<\/p>\n<p>Or<\/p>\n<p>&nbsp;<\/p>\n<p>b.2)<\/p>\n<p>As stated in the previous link simply do<\/p>\n<blockquote>\n<p class=\"comandi-cli-western\"><code class=\"western\">apt-get install libdatetime-perl libdatetime-format-mail-perl<\/code><\/p>\n<\/blockquote>\n<p>&nbsp;<\/p>\n<h1 class=\"western\">STEP 1<\/h1>\n<p>(Create files and dirs)<\/p>\n<p>a)<\/p>\n<blockquote>\n<p class=\"comandi-cli-western\">mkdir \/tmp\/mymail<\/p>\n<p class=\"comandi-cli-western\">mkdir \/tmp\/mymail\/mbox<\/p>\n<p class=\"comandi-cli-western\">cp -r ~\/.local\/share\/evolution\/mail\/local \/tmp\/mymail<\/p>\n<p class=\"comandi-cli-western\">cd \/tmp\/mymail\/local<\/p>\n<p class=\"comandi-cli-western\">find . -type d &gt; \/tmp\/mymail\/folderlist.txt<\/p>\n<p class=\"comandi-cli-western\">cd \/tmp\/mymail<\/p>\n<\/blockquote>\n<p>The file <em>\/tmp\/mymail\/folderlist.txt <\/em>contains lines such as.<\/p>\n<blockquote><p>.\/cur<br \/>\n.\/tmp<br \/>\n.\/new<br \/>\n.\/.IT<br \/>\n\/.IT\/cur<br \/>\n.\/.IT\/tmp<br \/>\n.\/.IT\/new<br \/>\n.\/.Tempo libero.Comics<br \/>\n.\/.Tempo libero.Comics\/cur<br \/>\n.\/.Tempo libero.Comics\/tmp<br \/>\n.\/.Tempo libero.Comics\/new<br \/>\n.\/.IT.FSFE-europe<br \/>\n.\/.IT.FSFE-europe\/cur<br \/>\n.\/.IT.FSFE-europe\/tmp<br \/>\n.\/.IT.FSFE-europe\/new<br \/>\n.\/.Societa.ATTAC<br \/>\n.\/.Societa.ATTAC\/cur<br \/>\n.\/.Societa.ATTAC\/tmp<br \/>\n.\/.Societa.ATTAC\/new<br \/>\n.\/.Outbox<br \/>\n.\/.Outbox\/cur<br \/>\n.\/.Outbox\/tmp<br \/>\n.\/.Outbox\/new<br \/>\n&#8230;<\/p><\/blockquote>\n<p>While in the \/tmp\/mymail dir and do<\/p>\n<blockquote>\n<p class=\"comandi-cli-western\">\/tmp\/mymail$ grep cur folderlist.txt &gt; folderlist1.txt<\/p>\n<p class=\"comandi-cli-western\">\/tmp\/mymail$ awk -F&#8221;\/&#8221; &#8216;{ print $2 }&#8217; folderlist1.txt &gt; folderlist.txt<\/p>\n<\/blockquote>\n<p>Now the file <em>\/tmp\/mymail\/folderlist.txt<\/em> contains in each line the name of the folder to be processed (all the folders are hidden as their names begin with a dot).<\/p>\n<p>&nbsp;<\/p>\n<p>a.2)<\/p>\n<p>This step is required <b>ONLY<\/b> if the name of at least one of the folders contains a blank (a space, like in &#8220;United Kingdom&#8221;).<\/p>\n<p>My wrap script can&#8217;t handle directory names with spaces, so those have to be processed by hand.<\/p>\n<p>To do that edit the file <em>\/tmp\/mymail\/folderlist.txt<\/em> and cut that folder names one by one and paste them in a file named like <em>\/tmp\/mymail\/ToBeProcessedByHand.txt<\/em> (what a name \ud83d\ude42 )<\/p>\n<p>(I end up processing 34 folders automatically and 4 by hand.)<\/p>\n<p>&nbsp;<\/p>\n<p>b)<\/p>\n<p>Edit the file <em>\/tmp\/mymail\/folderlist.txt<\/em> and remove the line for &#8220;cur&#8221; (the wrap script takes care of it).<\/p>\n<p>&nbsp;<\/p>\n<h1 class=\"western\">STEP 2<\/h1>\n<p><a href=\"https:\/\/dl.dropboxusercontent.com\/u\/20727857\/Doc+script+bin\/md2mb_allfolder.sh\">Download<\/a> the script<\/p>\n<p>OR<\/p>\n<p>copy a paste in a file named <em>md2mb_allfolder.sh<\/em> this:<\/p>\n<blockquote>\n<p class=\"comandi-cli-western\">#! \/bin\/bash<\/p>\n<p class=\"comandi-cli-western\">FOLDERLIST=\/tmp\/mymail\/folderlist.txt<br \/>\nDESTPATH=\/tmp\/mymail\/mbox\/<br \/>\nABSOLUTE_EXE=\/home\/mune\/bin\/maildir2mbox<br \/>\nBASEDIR=\/tmp\/mymail\/local<\/p>\n<p class=\"comandi-cli-western\">cd $BASEDIR<br \/>\nCOUNTER=1<\/p>\n<p class=\"comandi-cli-western\">while IFS=&#8221; read -r FOLDERNAME; do<br \/>\necho &#8220;Processing &#8220;$FOLDERNAME&#8221; &#8220;$COUNTER&#8221; &#8221;<br \/>\ncd &#8220;$FOLDERNAME&#8221;<br \/>\ncd cur<br \/>\nMBOXNAME=`echo $FOLDERNAME | cut -d &#8220;.&#8221; -f2-`<br \/>\n$ABSOLUTE_EXE &gt; $DESTPATH$MBOXNAME<br \/>\ncd ..\/new<br \/>\n$ABSOLUTE_EXE &gt;&gt; $DESTPATH$MBOXNAME<br \/>\ncd $BASEDIR<br \/>\nCOUNTER=$((COUNTER + 1))<br \/>\ndone &lt;$FOLDERLIST<\/p>\n<p class=\"comandi-cli-western\">FOLDERNAME=&#8221;INBOX&#8221;<br \/>\necho &#8220;Processing &#8220;$FOLDERNAME&#8221; &#8220;$COUNTER&#8221; &#8221;<br \/>\ncd cur<br \/>\nMBOXNAME=$FOLDERNAME<br \/>\n$ABSOLUTE_EXE &gt; $DESTPATH$MBOXNAME<br \/>\ncd ..\/new<br \/>\n$ABSOLUTE_EXE &gt;&gt; $DESTPATH$MBOXNAME<\/p>\n<p class=\"comandi-cli-western\">cd $BASEDIR<\/p>\n<\/blockquote>\n<p>Customize the wrap string to suit your directory structure.<\/p>\n<p>Make it executable (<em>chmod a+x &lt;path_to_script&gt;\/md2mb_allfolder.sh<\/em> ).<\/p>\n<p>&nbsp;<\/p>\n<h1 class=\"western\">STEP 3<\/h1>\n<blockquote>\n<p class=\"comandi-cli-western\">cd \/tmp\/mymail\/local<\/p>\n<p class=\"comandi-cli-western\">&lt;path_to_script&gt;\/md2mb_allfolder.sh<\/p>\n<\/blockquote>\n<p class=\"comandi-cli-western\">Federico Munerotto Jan 2016<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is ok for every mdir to mbox conversion but it specially suited if you move from the evolution mail client to the thunderbird one. STEP 0 &nbsp; a) retrieve required util from https:\/\/github.com\/jooooooon\/maildir2mbox<\/p>\n","protected":false},"author":1,"featured_media":181,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[52,43],"tags":[44,51,47,46,49,48,45,50],"class_list":["post-179","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","category-unix","tag-evolution","tag-folder","tag-mailbox","tag-maildir","tag-mbox","tag-mdir","tag-thunderbird","tag-wrap"],"_links":{"self":[{"href":"https:\/\/www.munerotto.it\/index.php?rest_route=\/wp\/v2\/posts\/179","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.munerotto.it\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.munerotto.it\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.munerotto.it\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.munerotto.it\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=179"}],"version-history":[{"count":6,"href":"https:\/\/www.munerotto.it\/index.php?rest_route=\/wp\/v2\/posts\/179\/revisions"}],"predecessor-version":[{"id":223,"href":"https:\/\/www.munerotto.it\/index.php?rest_route=\/wp\/v2\/posts\/179\/revisions\/223"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.munerotto.it\/index.php?rest_route=\/wp\/v2\/media\/181"}],"wp:attachment":[{"href":"https:\/\/www.munerotto.it\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=179"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.munerotto.it\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=179"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.munerotto.it\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=179"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}