Welcome to another automation post! This is a super simple Python script for changing misspelled or wrong tags in your Pinboard account. I started using Pinboard again because it helps me save all these great articles I read on the Interwebz, so I can paraphrase and regurgitate them back to you. Ha!
I need to clean out the Pinboard tags every so often because I hooked it up to Twitter. It works well for me because it saves all my retweets, favs and posts, but there’s a lot of noise. Sometimes I end up with tags like “DataScience” and “DataScientists” when I really want “DataScience.” I did some searching around and found the Pinboard Python library. Changing Pinboard tags with Python is EASY!
import pinboard pb = pinboard.Pinboard('INSERT_YOUR_API_KEY_HERE') old_tag = 'DataMining' new_tag = 'DataScience' pb.tags.rename(old=old_tag, new=new_tag)
You can, of course modify this script to pass command line arguments to it and just do something like this:
import pinboard import sys passcode = str(input('Enter your Pinboard API key here: ')) pb = pinboard.Pinboard(passcode) old_tag = str(input('Enter the old tag: ')) new_tag = str(input('Enter the new tag: ')) pb.tags.rename(old=old_tag, new=new_tag) print ('Converted: ' + old_tag+ ' to: ' + new_tag)
Once again, the second script is all open source and free for you to use/modify as you see fit.
Note: I just regurgitated the original script (first one) and then riffed on it for the second one. The Author of Pinboard provided a sample in the documentation. Check that out too!