"Automatic" Merging of Duplicates Using Keyboard Maestro (macOS only)
I recently had to migrate a large (>9k) items from Papers 3 to Zotero. The process involved migrating many individual collections to Zotero, which resulted in many (hundreds? thousands?) of duplicated in the zotero library. As many have mentioned, Zotero doesn't have a way to merge a large number of duplicates, so the user is forced to manually press "merge" on individual duplicates. It's not completely automatic and can fail to complete for a few reasons, but it did help me go through a lot of duplicates.
To solve this (somewhat) I wrote a short [Keyboard Maestro](http://www.keyboardmaestro.com/main/) macro to do this. If you want to take it for a spin without committing, I believe KM has a trial.
The macro simply clicks on each duplicate and presses the merge button. You do have to set up a few things before it works in your computer. Below is a quick explanation.
The macro requires that you have Zotero open and in the duplicate window, with the right panel where the "merge" button is visible. The macro clicks on an point (defined by you) somewhere on the list of duplicates (the middle panel of zotero), makes sure to move to the top of the list, and then clicks on the "merge" button. Rinse and repeat (set to a 1000 times, but the macro will stop if it can't find the merge button or something else goes wrong).
Here are the steps to use the macro:
1. Import the macro using KM.
2. Go to the macro and edit it in KM. You'll see two steps that read "Move and Click at (XX,YY)..." (in the attached file, XX=531, YY=81). These are the X,Y coordinates of the point in your screen that KM needs to click to select a (any) duplicate entry. Once you've positioned Zotero to run the macro (you shouldn't move it until it's done) you can press the "Get" button in the KM macro action "Move and Click..." and KM will grab the location after 5 seconds.
3. KM has a neat feature where it can click on anything on the screen that matches an image (screenshot) on the screen. I made this with an old-ish but retina MacBook pro, and the macro should work fine with all those. However, if the macro never presses the "merge" button, you might have to take a screenshot of that portion of the screen again and replace the image in that step of the macro.
Once you've set it up, go to the zotero duplicates list, click on any entry, and press the hot key combination assigned to the KM macro (you can change this, but it is currently ctrl-opt-command-z). A few other notes:
- The macro is set up to run for 1000 iterations (duplicates). You can change that number to 1 or 2 to give it a try. If one of the steps fails (e.g. the merge button is not there) the macro will stop running. You can also stop it by navigating away from Zotero, or use the "Cancel" macro menu in KM.
- The macro will stop and fail if Zotero fails to merge them (e.g. the items to be merged are of different kinds). You need to resolve that before you can move on.
The macro can be downloaded in my [github repository](https://github.com/moffat/keyboard-maestro). Feel free to point out problems or suggest smarter ways to solve this problem.
To solve this (somewhat) I wrote a short [Keyboard Maestro](http://www.keyboardmaestro.com/main/) macro to do this. If you want to take it for a spin without committing, I believe KM has a trial.
The macro simply clicks on each duplicate and presses the merge button. You do have to set up a few things before it works in your computer. Below is a quick explanation.
The macro requires that you have Zotero open and in the duplicate window, with the right panel where the "merge" button is visible. The macro clicks on an point (defined by you) somewhere on the list of duplicates (the middle panel of zotero), makes sure to move to the top of the list, and then clicks on the "merge" button. Rinse and repeat (set to a 1000 times, but the macro will stop if it can't find the merge button or something else goes wrong).
Here are the steps to use the macro:
1. Import the macro using KM.
2. Go to the macro and edit it in KM. You'll see two steps that read "Move and Click at (XX,YY)..." (in the attached file, XX=531, YY=81). These are the X,Y coordinates of the point in your screen that KM needs to click to select a (any) duplicate entry. Once you've positioned Zotero to run the macro (you shouldn't move it until it's done) you can press the "Get" button in the KM macro action "Move and Click..." and KM will grab the location after 5 seconds.
3. KM has a neat feature where it can click on anything on the screen that matches an image (screenshot) on the screen. I made this with an old-ish but retina MacBook pro, and the macro should work fine with all those. However, if the macro never presses the "merge" button, you might have to take a screenshot of that portion of the screen again and replace the image in that step of the macro.
Once you've set it up, go to the zotero duplicates list, click on any entry, and press the hot key combination assigned to the KM macro (you can change this, but it is currently ctrl-opt-command-z). A few other notes:
- The macro is set up to run for 1000 iterations (duplicates). You can change that number to 1 or 2 to give it a try. If one of the steps fails (e.g. the merge button is not there) the macro will stop running. You can also stop it by navigating away from Zotero, or use the "Cancel" macro menu in KM.
- The macro will stop and fail if Zotero fails to merge them (e.g. the items to be merged are of different kinds). You need to resolve that before you can move on.
The macro can be downloaded in my [github repository](https://github.com/moffat/keyboard-maestro). Feel free to point out problems or suggest smarter ways to solve this problem.