How to remove duplicate Open With menu items in Finder

I often find that the Open With context menu in Finder has duplicate entries for some applications. The most reliable way I’ve found of fixing it is running the following command in Terminal and relaunching Finder ( > Force Quit… then select Finder and click Relaunch button).