Several months ago I began to more thoroughly tag things as I bookmarked them, adding in things like the publication year, authors, and source websites. Unfortunately, this meant that I had several years of bookmarks without these tags. This information is particularly useful with my free music bookmarks, allowing me to quickly find all albums from a given year or artist.
The specific problem that inspired this post was a wish to find everything I’d
bookmarked from the Internet Archive that didn’t have the associated
src:archive.org tag. Although delicious has a little-known
system:has:x search, it doesn’t have a negation operator.
But! Because delicious has a nice API, we can get around this limitation by stringing together a few command line tools.
How it works
(Note: the following assumes a command prompt and a Mac or Linux system, and is written from the perspective of a Mac. I don’t know how this would be accomplished with Windows, and don’t particularly care.)
Because we can’t do this via the web, we’ll download a copy of our bookmarks and work locally:
curl --user username:password -o ~/Desktop/delicious.xml -O 'https://api.del.icio.us/v1/posts/all'
Inserting your own delicious username and password in the appropriate spots. Try not to do this too often, because a large number of bookmarks means a lot of work for the servers.
Now to do the actual processing:
cat delicious.xml |grep archive.org |grep -v src:archive.org > del.txt
What this line does:
- opens the file that holds our downloaded bookmarks
- hands it over to grep, which
- looks for bookmarks that include the text
archive.org(i.e. they’re from the site) - but not (
-v)src:archive.org(they’re missing the tag) - then spits the results into a new text file
Finishing up
From there, we can just open the text file and add in the tags via the web interface.
Not an especially elegant solution (particularly as adding the tags is a slow process), but still much simpler than checking every link manually through the website.