joeyates / imap-backup

Backup and Migrate IMAP Email Accounts
MIT License
1.33k stars 74 forks source link

[Question] How to migrate to a sub-folder? #159

Closed jxmesth closed 12 months ago

jxmesth commented 1 year ago

Lets say I have a folder in outlook called Email2 which is under the parent folder Email1.

How do I, making use of delimiters, migrate all emails (folders and subfolder) inside the Email2 sub-folder in secondary email?

joeyates commented 1 year ago

Hi @jxmesth, thanks for the question.

First, you need to know how the source provider (Outlook) handles names of subfolders - their "Delimiter". Do they call them "Email1/Email2" or "Email1.Email2".

To do this, you can use the imap-backup namespace command.

For example if you query the Outlook account, you might see something like this:

imap-backup namespace me@example.com
Name       Prefix     Delimiter
personal   ""         "."
other      (Not defined)
shared     (Not defined)

In this case, the delimiter is the "." character.

If I understand your situation correctly, you need to migrate the content of "Email1.Email2" on one account to a folder called "Email2" on the other account.

To do so, you need to provide the source prefix and delimiter:

imap-backup migrate ACCOUNT1 ACCOUNT2 --source-prefix=Email1 --source-delimiter=.

Obviously, you need to check the delimiter for your email provider, and also you need to perform a backup first.

Let me know how it goes!

jxmesth commented 12 months ago

Hi @joeyates, apologies for the late reply. I've just gotten round to testing this and apparently I can't get this to work.

When I run the namespace command: imap-backup namespace me@google.co.uk

I get: Could not find command "namespace".

In addition to this, I just wanted to clarify what you mentioned above. To migrate all emails (folders and sub-folders) from me@google.co.uk to new-me@google.co.uk/me@google.co.uk, I need to run this: imap-backup migrate me@google.co.uk new-me@google.co.uk --source-prefix=new-me@google.co.uk --source-delimiter=.

If I'm not mistaken this should make a folder in my new-me@google.co.uk email called me@google.co.uk that contains sub-folders - Inbox, Sent, Drafts, etc. from my me@google.co.uk email.

So ideally running this command would give me this:

new-me@google.co.uk/
├─ Inbox/
├─ Sent/
├─ Deleted/
├─ me@google.co.uk/
│  ├─ Inbox/
│  ├─ Sent/
│  ├─ Deleted/

Thanks again.