Spostamento di una gerarchia Maildir sotto un'altro account
Jump to navigation
Jump to search
Script per rename di tutta una mailbox
Questo script crea una gerarchia Maildir che parte dalla cartella .NewPrefix a partire da una Maildir completa.
Lo script va lanciato da una cartella che si chiama Maildir che contenga i folder cur new tmp e i sottofolder.
#!/bin/bash
if [ -z $1 ]
then
echo "Usage: rename_maildir newPrefix"
exit 1
fi
PRF="$1"
# Move subfolders
if [ "$(basename $(pwd))" = "Maildir" ]
then
find . -name ".[[:alnum:]]*" -printf '%f\n' | \
while read MBX; do
mv "${MBX}" ".${PRF}${MBX}"
done
else
echo "You must run this command from a directory named Maildir. Aborting."
exit 1
fi
# Move inbox
mkdir .$PRF
mv cur .${PRF}/
mv new .$PRF/
mv tmp .$PRF/
mv dovecot* .$PRF/ > /dev/null 2>&1
mv courier* .$PRF/ > /dev/null 2>&1
Script per rename e spostamento
Questo script sposta tutta la posta dell'account sorgente in una sottocartella dell'account destinazione.
Uso:
sudo /tmp/sposta_maildir src_account dst_account
cat > /tmp/sposta_maildir <<'EOFile'
#!/bin/bash
SRC="$1"
DST="$2"
SRC_CLEAN=$(echo $SRC | tr . _)
if [ "$(id -u)" -ne "0" ]
then
echo You must be root to run this script. Aborting.
exit 127
fi
if [ -z "$1" -o -z "$2" ]
then
echo Usage: sposta_maildir src_account dst_account
exit 127
fi
if [ ! -e /home/${SRC}/Maildir ]
then
echo /home/${SRC}/Maildir does not exist. Aborting
exit 127
fi
if [ ! -e /home/${DST}/Maildir ]
then
echo /home/${DST}/Maildir does not exist. Aborting
exit 127
fi
echo Moving /home/${SRC}/Maildir to /home/${DST}/Maildir/.${SRC_CLEAN}
cd /home/${SRC}/Maildir
for VAR in .*
do
if [[ "$VAR" != "." && "$VAR" != ".." ]]
then
set -x
mv "$VAR" ".${SRC_CLEAN}$VAR"
set +x
fi
done
#set -x
mkdir .${SRC_CLEAN}
mv cur .${SRC_CLEAN}
mv new .${SRC_CLEAN}
mv tmp .${SRC_CLEAN}
mv .${SRC_CLEAN}* /home/${DST}/Maildir
#set +x
chown -R ${DST}: /home/${DST}/Maildir
EOFile
chmod +x /tmp/sposta_maildir