quentinsf / IMAPdedup

IMAP message de-duplicator
https://quentinsf.com/software/imapdedup
GNU General Public License v2.0
321 stars 57 forks source link

Execute in All Folders #43

Closed edufa closed 4 years ago

edufa commented 6 years ago

I have some accounts with a large number of folder (+100) :(

ericschaetzlein commented 5 years ago

I'd love that feature too!

Xiphe commented 4 years ago

I would love to remove mails from a specific folder when there are duplicates in ANY other folder.

quentinsf commented 4 years ago

I should probably add an 'all folders' option, and it's easy to do. (It wouldn't work for me because I have enough mail in my archive folders that I think I'd run out of memory before it completed!).

At present, you can specify multiple folders on the command line, and it will search them in order, deleting duplicate messages from the later ones if they have been found in the earlier ones.

So yes, if we added 'All folders', we'd need a way to specify which ones came first.

One way, in the meantime, would be to use the '-l' option to list all your mailboxes to a file, sort them as you like in a text editor, and then run imapdedup using xargs to read all of the folder names from the file...

Xiphe commented 4 years ago

That worked really well! thanks for the hint @quentinsf

I printed all folders using -l copied them into an editor, ordered them and wrapped " now i have a list that i can paste and all works well!

Mallewax commented 4 years ago

I'd love that feature too!

Same here. I also have so many folders and a recursive deduplication would be extremely helpful.

Mallewax commented 4 years ago

That worked really well! thanks for the hint @quentinsf

I printed all folders using -l copied them into an editor, ordered them and wrapped " now i have a list that i can paste and all works well!

@Xiphe: Can you please illustrate this with an example? I am not that savvy and can surely use some help. Still hoping that @quentinsf will include the "-all folder" feature....:-)

quentinsf commented 4 years ago

Here's a quick demo. Imagine you normally run this with:

./imapdedup.py -x -s servername -u username -w password ...

You can save your list of folders to a file called folders.txt like this:

./imapdedup.py -x -s servername -u username -w password -l > folders.txt

The xargs utility lets you read words (or lines) from the standard input, and run any command passing those words as arguments to the command, so you can do something like this (I've included the -n so it's a dry run and should be safe if you try it!):

cat folders.txt | xargs ./imapdedup.py -x -s servername -u username -w password -n

xargs will basically run imapdedup with all the folder names in folders.txt passed as arguments as if you had typed them on the command line. As @Xiphe points out, if your folder names have any spaces in them, you should open the text files in an editor and put quotes around each line that has them.

This method, though slightly tedious, has the big advantage that you can edit folders.txt to remove certain folders, or to change the order. Duplicates will be deleted from the later folders if they existed in the earlier ones. That's the kind of decision that would be harder to make in a simple 'all folders' option...

All of this does require you to be running on Linux or a Mac. Much harder to do anything like this on Windows, of course!

Mallewax commented 4 years ago

Genius. Thank you very much. I understand and will try this.

Quentin Stafford-Fraser wrote on 7/20/20 14:05:

Here's a quick demo. Imagine you normally run this with:

|./imapdedup.py -x -s servername -u username -w password ...|

You can save your list of folders to a file called folders.txt like this:

|./imapdedup.py -x -s servername -u username -w password -l > folders.txt|

The xargs utility lets you read words (or lines) from the standard input, and run any command passing those words as arguments to the command, so you can do something like this (I've included the -n so it's a dry run and should be safe if you try it!):

|cat folders.txt | xargs ./imapdedup.py -x -s servername -u username -w password -n|

xargs will basically run imapdedup with all the folder names in folders.txt passed as arguments as if you had typed them on the command line. As @Xiphe https://github.com/Xiphe points out, if your folder names have any spaces in them, you should open the text files in an editor and put quotes around each line that has them.

This method, though slightly tedious, has the big advantage that you can edit folders.txt to remove certain folders, or to change the order. Duplicates will be deleted from the /later/ folders if they existed in the earlier ones. That's the kind of decision that would be harder to make in a simple 'all folders' option...

All of this does require you to be running on Linux or a Mac. Much harder to do anything like this on Windows, of course!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/quentinsf/IMAPdedup/issues/43#issuecomment-661247123, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQCBURZRUBNRCEJTWSXUSNTR4SBOPANCNFSM4E5JM7QA.

quentinsf commented 4 years ago

Am closing this now as I've added it to the README