Blogger Hacks, Categories, Tips & Tricks

Monday, August 21, 2006
Scripted Re-Mark: Batch Editing Your Bookmarks
Many bloggers like to bookmark their posts in del.icio.us, whether for their own reference, categories or just getting their links out there. Dealing with a large of collection of bookmarks can be quite unwieldy, especially if you're used to modern niceties likes search-and-replace, macros, wildcards and other "luxuries". Picking out and treating your bookmarks one at a time can be dispiriting. This post introduces a new service I knocked together over the weekend that makes it easy to update and edit your bookmarks wholesale.

The service is dubbed Scripted Re-Mark, since you use a script to "re-mark" your bookmarks. It grew out of my earlier experiments with automatic tagging and frustrations with migrating a blog.

*** Update ***

(There's a new release for Scripted Re-Mark that features zippier updates and functions-as-parameters.)

To use the service, you visit the page, play around with some search/replace rules and then copy/paste a code snippet into another window, opened up to your del.icio.us account. The code snippet zips through the bookmarks, making changes and saving the result.

You can search/replace on the Title, URL, Notes and Tags of your bookmarks, using as many rules as you like. (And, yes, you can use full regular expressions!) You can also set the sharing (public/private) properties. The service deals with the del.icio.us "rate limiter" for you, ensuring that you don't get locked out of your account for thrashing their servers.

Some possible uses:
  • Site Migration: Change the domain name in the URLs of a bunch of bookmarks.

  • Spelling Correction: As a favour, why not fix all the different flavours of spelling, without too much labour?

  • Tag Migration: Delete, merge and rename tags in one hit. Or, add a common tag across a subset of your bookmarks to help with grouping.

  • Share your Imports: By default, imported bookmarks are private; set them all free with a mass "tag and release program".


If you've got more ideas, please share them in the comments, including any regular expressions you come up with.

I've tested it under FireFox and Internet Explorer (I wept tears getting it to work in IE ...) but not Safari or Opera. If someone could let me know how it travels, that'd be great. Still, this is "beta" (not like Google - I mean beta) so please backup your bookmarks before committing anything.

The code is released under a Creative Common licence so feel free to "extend and embrace". Future ideas include allowing generic functions in the replace string, rolling in the auto-tagger for suggestions, deletion and, well, you tell me!

Filed in: , , , ,
Posted at 11:17 AM by Greg.
46 Comments:
<    >
Blogger John said...
"As a favour, why not fix all the different flavours of spelling, without too much labour?"

Then you can go to the Harbor...

<    >
Anonymous phydeaux3 said...
Wow. Nice work Greg!!!

I haven't given a complete test run because I don't actually need the use of it now. But I could've definitely used this several months ago (This would have saved me a TON of time)...and see where I might in the future make use of it.

Looks great. Excellent job.

<    >
Blogger Greg said...
Thanks, phydeaux3.

I hope people find it useful for eliminating the boring rote stuff in looking after bookmarks (displacement). I also hope people can think of innovative new uses for it too (disruption)!

<    >
Blogger Aditya said...
Sweet! And I mean sweet! I'll give this a trial run the moment I get some time off from classes in Uni! :)

<    >
Anonymous Anonymous said...
Any way to use this to publish all of your bookmarks to be public? Can't see how to do this. Delicious support sent me to this page btw.

please email me traemccombs {isat} gmail {dot} com if you know the answer of how to get all of your bookmarks published in one swoop.

tx.
Trae

<    >
Blogger Greg said...
Hi Trae,

Sure - just set the "Bookmark Sharing" option to "Set Public".

Leave the search/replace rules blank and follow the instructions. Easy!

(And thanks for letting us know that we're on the Delicious Support radar.)

<    >
Blogger Greg said...
Oh yeah - as explained in the instructions, you'll need to set enable your account for private bookmarking. This puts a little "do not share" checkbox on your page, which my script uses to set your bookmarking option (public or private).

Alternatively, you can try an earlier single-purpose hack that is less sophisticated.

<    >
Blogger Greg said...
Just had a thought for extensions to this - what about pulling in tag synonyms from Singpolyma's Tagging service?

It would be nice if you could indicate a heirarchy, so that a tag could get
"promoted" to a more useful (=popular) variant. Eg "web-2.0" is detected and replaced with "web2.0". Combined with the auto-taggging suggestor and you'd have neat way to populate and tidy your tags.

Since JavaScript 1.5+ supports using functions as the replacement value, it should be fairly low-impact to make such extensions.

<    >
Blogger John said...
Greg,

Love this idea! I've been doing a lot of thinking lately about "better ways to belong" in the blogosphere, & being able to "find & replace" on a more popular but synonymous tag would bring some consistency, as well as raising the profile of your content & opening it up to more people. Very cool...

<    >
Blogger Johan Sundström said...
Very neat! I think the helpful link to regexp docs wasn't quite as helpful as intended, though. ;-) It might be worth mentioning it's the javascript RegExp variant, as there are quite a few different makes floating around, all with slightly different syntax.

<    >
Anonymous Anonymous said...
I'd like to create canonical tags by converting them to lowercase. I can't find the equivalent to s/PAT/lc{&}/, or a tolower(). Is there a better way than 26 rules for A->a ... Z->z?

<    >
Blogger Angela said...
Love this script!!! Took me a few minutes to realize that it wouldn't work in Firefox (or at least I couldn't get it to work), but it works perfectly in IE. Yippie!!! No spending forever editing tags. I do agree with another person on changing the syntax/capitalization/etc. But, hey, at least we can do some bulk editing. It's a shame that delicious couldn't come up with something themselves. Not to mention the annoying issue of making every import automatically private. Argh.

<    >
Blogger Greg said...
Re: lowercase. Um, not sure. I don't think there's a way to do that with regexps. The next release should let you pass a function into the replace string, but that won't help you now. I guess the 26 A->a rules is the best alternative at the mo'.

Re: FireFox. Sorry to hear it didn't work for you. I developed and tested it in FF, only adding support for IE after the fact. So it's weird to have problems. Can you outline a little more what your issue was?

<    >
Blogger Blaise Astra said...
Hi Greg,

I also wasn't able to get this to work in FF (or IE7, for that matter). I was trying to batch edit to make all my private links public, and I followed the instructions you gave above. What happened was that the script seemed to be working, it ran down the page and looked at each bookmark, but when it got to bookmarks that were private, it simply didn't change them. Incidentally, I also tried your auto-tagger, and it didn't work for me either. Could it be because I'm using FF 2.0? Or is there some setting I should change somewhere? Thanks for a great script, even if it doesn't work for me! :)

<    >
Anonymous Anonymous said...
I agree with Blaise Astra. It worked for me for awhile, but stopped working in ie 6 and FF 1.5.0.7

atebark...yahoo

<    >
Anonymous anbs said...
I am trying to convert my public bookmarks to "private", but having trouble. The script actually runs, but the changes are not being made to the bookmarks. This is a great idea though!

<    >
Anonymous anbs said...
It looks like the field/input mapping has changed. I was able to get it to work after changing the field number for the sharing setting to "9" (from 8). Thanks for the script!

<    >
Blogger Greg said...
Thanks, anbs, for looking into this.

I'm presently traveling in Asia so I won't be in a position to make any changes until the New Year.

For those with the knowledge, please update the field changes as explained above. I'll leave a note here when I've fixed it up.

<    >
Blogger Greg said...
Thanks again, everyone, for your help on this one. The new release has been launched. It's fixed up and has some new features (including functions-as-parameters!).

Please add future comments to the new post.

-Greg.

<    >
Blogger redw0rm said...
Wow - phenomenal. I'm working on something that I have to keep on the down-low for a while. I just privatized 76 of my delicious bookmarks in one fell swoop. Your hack is also great because once this thing is public, it will be easy to do the right thing and go back and make all those bookmarks public again. Takk!

<    >
Blogger Greg said...
Thanks, redw0rm.

Please check out the new features on Scripted Re-Mark: tag stemming and "touched tags".

<    >
Anonymous Anonymous said...
This script is broken. It inserts the "touched" tags into the notes field! Screwed up all my bookmarks.

<    >
Blogger Greg said...
Really? I'm sorry to hear that. I just tested it out on my test account and it worked fine (check it out).

Can you please provide your account name so I can have a look. I'd be delighted to find out what went wrong for you and work out a rule to help correct the damage done (if you didn't back up first).

Speaking of not following the instructions, one possibility is that you didn't have "enable private sharing" turned on - did you check this?

-Greg.

<    >
Blogger Stian said...
Your script works great for what it is meant to do, Greg. Thanks for making it available! However, my imported bookmarks currently have all their tags in the 'notes' field, and I would of course like to move them all to the currently empty 'tags' field, leaving the 'notes' field blank. Unfortunately, my JS knowledge is just too limited to see how to perform "cross-field" operations like that with your script... Any ideas? Thanks!

<    >
Blogger Greg said...
Hi Stian,

Yeah, it would be a bit of work re-jigging it like that.

(I'll keep your unusual "use case" in mind for future releases.)

If you don't have a huge number of tags, you could try this:

* Set it to search in the notes field for your tag (say, "movies").

* Replace it with the empty string, so it will delete that tag from the notes.

* Set the "touched" tag to "movies".

* Execute.

* Rinse and repeat for each of your tags.

I know, painful, but it will work.

Cheers,

-Greg.

<    >
Blogger Rick said...
I had just deleted over one thousand unfiled bookmarks, and was halfway through the second page of resetting the privacy on the rest of my bookmarks, when the process froze. Subsequent attempts to access the delicious website caused a 999 error (spyware, virus, unusual activity). Apparently Yahoo! didn't like all that modifying!

<    >
Blogger Christian Skoda said...
Is this script still supported? I tried to mass-edit all my tags, which were saved unfortunately with commas instead of spaces between tags. :-/

So simply removing ',' in tags.

All went fine in the test window. Copy and paste into bookmark window as well and it automatically runs through all the bookmarks.

But: nothing is changed. Commas are still attached to tags, the result doesn't look like in the test pane.

Tried in FF2.0.0.13 and IE7.

Please help!

;-)

<    >
Blogger Greg said...
Hi Christian,

Yeah, it's still working. I just used it to add and then remove commas from my tag lists.

Did you use a comma-removal script like this?

[Replace http with javascript in the link provided; Blogger security issue.]

If you're still stuck, please leave your del.icio.us username and I can have a look for you.

<    >
Blogger Christian Skoda said...
I tried again to no avail. Only the preview looks okay. The script looks like this:

delay=2; ruleSet=[[3,/,/gi,""]]; sharing=2; touched=""; var s=document.createElement("script"); ...

My username is krissz. Almost all but some bookmarks feature usless commas instead of spaces separating bookmarks. Talk about 'automatic' submission. ;-)

<    >
Blogger Greg said...
Hi again,

I'm not sure what to say - it works for me! I know, not very helpful.

I modded a subset of my delicious to be like yours ie separated by a comma-space ie ", "

http://del.icio.us/thetan/touched

(I've left three entries here to confirm it's the same.)

Then I added the rule you specified by doing a direct copy-paste from your comment. The code fixed it (ie made all the tags on the current page separated by spaces).

I've done this four times now, just to confirm it wasn't a fluke.

Can you elaborate more on what sorts of errors or failures you're seeing?

Or maybe it's not throwing an error, but doing something different or unexpected? What did you have in mind should be happening?

-Greg.

<    >
Blogger Christian Skoda said...
There isn't any error message when I do it. When the script starts it opens a small grey box for every boomark and goes through all bookmarks on that page step-by-step. But no changes appear and no message at all. I tried a at least half a dozen times with different script settings.

Greg, I could give you my login credentials, if you want to try it out with my live bookmarks?

My bookmarks are anyway useless if I can't fix that problem.

If you want to give it a try, just drop me a mail to the address in my profile page and I send you the password.

<    >
Blogger Winston said...
Just came across this script, and I must say it's great work! Thanks!

However, the "tag tidy" button isn't really working for me.

Example:
I have a search and replace rule for "comment" to "comments". When the rule encounters the tag "comments", it will change it to "commentss", which is not what I want.

Is there any work around for this? Thank you!

<    >
Blogger Ryan said...
Unfortunately, it seems that the del.icio.us --> delicious.com changeover wreaked havoc with your script. I get about 10 error messages in the Console when I attempt to run it on the new design. Sad. Yet another thing that del.icio.us broke this week.

<    >
Blogger jlr said...
I'm dying for this function, but it's just... not working. I pasted the script into the address bar and hit enter and nothing happened (in both Firefox and Safari). Are there updates necessary for the redesigned delicious? If so, I will wait patiently.

<    >
Blogger John said...
When will this service be updated to work with the new delicious release?

<    >
Blogger Greg said...
Hi people,

Thanks for drawing to my attention the impact of the new delicious.com site design on the Scripted Re-Mark service.

I've looked into it and, yes, it's broken.

Can it be fixed? Yes, but sadly, probably not by me. I've taken a cursory look at the code, which has been sufficient for previous re-designs.

Now, it's beyond my ken what the hell is going on. I might have a look at it when I'm less burnt from thesis-writing, but in the mean time, I urge any JavaScript gurus out there to get in touch with me.

(The gist of the problem is that I don't know which function is called in when one clicks the "edit" link on the new page, so I can't induce the clickety-click via script ie editPost in the old version.)

So, sorry. The people at Delicious have been promising a batch editing tool for about two years, while pointing people to this tool as a stop-gap. Perhaps something will eventuate on that front?

In any case, if I fix it or someone else helps me, I will be sure to post back here to let you all know.

<    >
Blogger Greg said...
Should be fixed now.

I've tested it under FF and IE and all functionality seems okay (toggle public/private, regular expressions, mass delete etc).

It's not been exhaustively tested, so please note any issues you're having below and I'll endeavour to follow it up.

<    >
OpenID drobbins said...
Excellent tool - thank you. I ran into one bug, which is minor in scope. I found that if you have a bookmark title that ends in a question mark (or I imagine one that contains one anywhere, though I'm not certain), the script gets out of whack (I'm guessing its just the arrays get out of order). Now I've got a bunch of bookmarks that have "touched" added to their title (instead of as a tag). LOL! It will be an easy fix, thanks to your tool, once I change the bookmark that caused it. I have no idea how this would be resolved via code, but I wanted to point it out to you all the same.

<    >
Anonymous Anonymous said...
Great idea, but I can't get it to work at all. In the Enter details it always says: No bookmarks: Please check del.icio.us username and filter tags.

I tried in FF, Safari on Mac, Then IE on Windows with always the same result.

Thanks

Rich

<    >
Blogger Greg said...
Hi Rich,

Thanks for taking the time to file a bug report. I'm not sure what to say other than the dreaded "but it works for me!"

I've tried a few delicious usernames and filter tags (and absence of filter tags) and it seems okay.

Did the default details work for you? Ie Joshua's (delicious' creator) bookmarks for food in NYC?

Perhaps there's some particular weird character or something in your feed. Would you mind disclosing the username (and any filter tags) you've been using?

<    >
Blogger Richard said...
Hi,

User name is Hawkcode

Tag is ACTIVE

And default is returning 59 bookmarks.

Rich

<    >
Blogger Greg said...
Hi Rich,

I can confirm that it does work with username Hawkcode and no filter tags (2 results returned). When I check your delicious account I can only see two bookmarks, none of which have been tagged ACTIVE.

Maybe you have a bunch of other bookmarks, but if they are marked private you can't preview them with this tool.

But don't worry, you can still create rules and apply them as usual to private bookmarks.

To make sure the rules are having the desired effect, perhaps you could unprivate a few of them so the preview feature works. If not, just suck it and see! (Please remember to backup your bookmarks first.)

<    >
Anonymous Anonymous said...
Is it possible to set share from private to public *within a certain period? Eg. everything from 13 aug 2004 and earlier?

I imported a lot of spurl bookmarks that are set to private ehivh I want to share - but I also have private items I want to keep....

<    >
Blogger Greg said...
The short answer is no, sadly.

It's a good suggestion and one I'd like to implement, but the JSON feed the delicious API provides does not include date information.

If there's no tags unique to the spurl imports, unfortunately, you might have to filter by hand.

The best I can suggest is to use patterns (like matching "https://") to to automate some of the work.

<    >
Blogger djk said...
Thankyou thankyou thankyou!
I can't believe one can't do this kind of stuff with the del.icio.us Firefox extension.

<    >
Blogger jlr said...
I'm thrilled that this tool is up and running for delicious 2.0! It worked perfectly for me.

Just wanted to make a note for anyone who's trying to troubleshoot: make sure you're LOGGED IN to the delicious account you're editing. This was my problem when it wasn't functioning for me at first, but it took me some time to figure that out. *facepalm*

Also keep in mind that you'll have to redo your tag bundling for any touched tags.

Links to this post:

Create a Link


eXTReMe Tracker