From: Paul Mangan Date: Tue, 27 May 2003 22:23:13 +0000 (+0000) Subject: add kmail to sylpheed mailbox conversion script X-Git-Tag: rel_0_9_3~112 X-Git-Url: http://git.claws-mail.org/?p=claws.git;a=commitdiff_plain;h=72580750ea6fbe8757bdc6cf754bd540a39f579c add kmail to sylpheed mailbox conversion script --- diff --git a/ChangeLog.claws b/ChangeLog.claws index 0a7938d65..97cae6b3b 100644 --- a/ChangeLog.claws +++ b/ChangeLog.claws @@ -1,3 +1,9 @@ +2003-05-27 [paul] 0.9.0claws4 + + * tools/Makefile.am + tools/maildir2sylpheed.pl ** NEW FILE ** + add kmail to sylpheed mailbox conversion script + 2003-05-27 [paul] 0.9.0claws3 * sync with 0.9.0cvs10 diff --git a/configure.ac b/configure.ac index 1a025a508..50a4e6096 100644 --- a/configure.ac +++ b/configure.ac @@ -11,7 +11,7 @@ MINOR_VERSION=9 MICRO_VERSION=0 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=claws3 +EXTRA_VERSION=claws4 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION dnl set $target diff --git a/tools/Makefile.am b/tools/Makefile.am index e0798b111..2e578b4a6 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -12,6 +12,7 @@ EXTRA_TOOLS = \ kmail2sylpheed.pl \ kmail2sylpheed_v2.pl \ launch_phoenix \ + maildir2sylpheed.pl \ multiwebsearch.pl \ newscache_clean.pl \ outlook2sylpheed.pl \ diff --git a/tools/maildir2sylpheed.pl b/tools/maildir2sylpheed.pl new file mode 100644 index 000000000..d2ffcad4a --- /dev/null +++ b/tools/maildir2sylpheed.pl @@ -0,0 +1,135 @@ +#!/usr/bin/perl + +# * Copyright © 2003 Paul Mangan +# * +# * This file is free software; you can redistribute it and/or modify it +# * under the terms of the GNU General Public License as published by +# * the Free Software Foundation; either version 2 of the License, or +# * (at your option) any later version. +# * +# * This program is distributed in the hope that it will be useful, but +# * WITHOUT ANY WARRANTY; without even the implied warranty of +# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# * General Public License for more details. +# * +# * You should have received a copy of the GNU General Public License +# * along with this program; if not, write to the Free Software +# * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +## script name : maildir2sylpheed.pl + +## script purpose : convert a Kmail mailbox into a Sylpheed mailbox + +## USAGE: maildir2sylpheed.pl --kmaildir=Mail + +## tested with Kmail 1.5.2 + +use Getopt::Long; +use File::Recurse; + +$kmaildir = ''; +$iNeedHelp = ''; + +$sylpheed_tmpdir = "sylpheed_tmp"; +$kmail_olddir = "kmail_junk"; + +GetOptions("kmaildir=s" => \$kmaildir, + "help" => \$iNeedHelp); + +if ($kmaildir eq "" || $iNeedHelp) { + if (!$iNeedHelp) { + print "No directory name given\n"; + } + print "Use the following format:\n"; + print "\tmaildir2sylpheed.pl --kmaildir=mail_folder_name\n\n"; + print "For example: 'Mail'\n"; + exit; +} + +chdir($ENV{HOME}); + +$MAIL_dir = "$ENV{HOME}/$kmaildir"; + +mkdir("$sylpheed_tmpdir", 0755); + +my %files = Recurse(["$MAIL_dir"], {}); + +foreach (keys %files) { + $dir = $_; + push(@dirs, "$_"); + foreach (@{ $files{$_} }) { + push(@files, "$dir/$_"); + } +} + +foreach $direc (@dirs) { + if ($direc !~ m/^drafts$/ + && $direc !~ m/^outbox$/ + && $direc !~ m/^trash$/ + && $direc !~ m/^inbox$/) { + $tmpdir = $direc; + $tmpdir =~ s/^$MAIL_dir//; + $tmpdir =~ s/sent-mail/sent/; + $tmpdir =~ s/\/cur$//; + $tmpdir =~ s/\/new$//; + $tmpdir =~ s/^\///; + $tmpdir =~ s/\.directory//g; + $tmpdir =~ s/\.//g; + mkdir("$sylpheed_tmpdir/$tmpdir"); + opendir(DIR, "$direc") + || die("Can't open directory"); + push(@subdirs,(readdir(DIR))); + closedir DIR; + } + + foreach $subdir (@subdirs) { + if ($subdir !~ m/\.directory$/ + && $subdir!~ m/^\.*$/ + && $subdir !~ m/cur\/$/ + && $subdir !~ m/new\/$/ + && $subdir !~ m/tmp\/$/) { + $sub_dir =~ s/\.directory//; + unless (-e "$sylpheed_tmpdir/$tmpdir/$sub_dir") { + mkdir("$sylpheed_tmpdir/$tmpdir/$sub_dir"); + } + } + } +} + +$count = 1; +foreach $file (@files) { + $tmpfile = $file; + if ($tmpfile =~ m/\/cur\// + || $tmpfile =~ m/\/new\//) { + $tmpfile =~ s/\/new//; + $tmpfile =~ s/\/cur//; + @spl_str = split("/", $tmpfile); + pop(@spl_str); + push(@spl_str, "$count"); + foreach $spl_str (@spl_str) { + $spl_str =~ s/^\.//; + $spl_str =~ s/\.directory$//; + $spl_str =~ s/sent-mail/sent/; + } + $nfile = join("/", @spl_str); + $nfile =~ s/\/$kmaildir\//\/$sylpheed_tmpdir\//; + } + + if (-e "$file" && $nfile ne "") { + system("cp \"$file\" \"$nfile\""); + $count++; + } +} + +system("mv $kmaildir $kmail_olddir"); +system("mv $sylpheed_tmpdir $ENV{HOME}/Mail"); + +print "Sucessfully converted mailbox \"$MAIL_dir\"\n"; +print "Start Sylpheed and right-click \"Mailbox (MH)\" and "; +print "select \"Rebuild folder tree\"\n"; +print "You may also need to run \"/File/Folder/Check for " +print "new messages in all folders\"\n\n"; +print "Your kmail directories have been backed-up to\n"; +print "$ENV{HOME}/$kmail_olddir\n\n"; + +exit;