I am trying to execute the following commands in Terminal for Magento 2 found here https://www.cadence-labs.com/2017/11/magento-2-fix-duplicate-url-key-for-categories-and-products/.
cadence:urldedup:categories Dedup Category url rewrites across stores
cadence:urldedup:products Dedup Product url rewrites across stores
However, it's returning the following:
The filename, directory name, or volume label syntax is incorrect.
I googled a lot but didn't find anything relevant to this issue. If anybody has a solution to this, please share.

You should run the command like following in Magento2 root.
php bin/magento cadence:urldedup:products
It will work for you.