Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to batch rename Tumblr tags?

Tags:

tags

api

tumblr

I have tagged over 700 blog posts with tags containing hyphens, and these tags suddenly stopped working in 2011, because Tumblr decided (without any notice) to forbid hyphens in tags (I guess hyphens are blocked now, because spaces in tags (which are allowed) get changed to hyphens.). Unfortunately, Tumblr is not willing to globally rename all tags containg hyphens (although these tags are of no use anymore → 404).

Now I want to rename my tags myself.

I tried to do it with the "Mass Post Editor" (tumblr.com/mega-editor), but it's not possible to select posts by tag. I'd have to manually select post after post and look if a certain tag was used, and if so, delete it and add a new one instead. This would be a huge job (700 tagged posts, but more than 1000 in total).

So I thought that the Tumblr API might help me. I'm no programmer, but I'd be willing to dig into it, if I could get some help here as a starting point.

I think I need the following process:

  1. select all posts that are tagged with x (= a tag containing hyphens)
  2. tag all these posts with y (= a tag without hyphens)
  3. delete the tag x on all these posts

I'd start this process for every affected tag manually.


I see that the method (or whatever you call it) /post knows the request parameter tag:

Limits the response to posts with the specified tag

(I guess I can only hope that this works for tags containing hyphens, too.)

After that I'd need a way to add and remove tags from that result set. /post/edit doesn't say anything about tags. Did I miss something? Isn't it possible to add/remove tags with the API?


Have you an idea how I could "easily" rename my tags?

Is it possible with the API? Could you give me a starting point, tip etc. how I could manage to do it?


I don't know if this might be helpful, but I noticed that the search function is still able to find posts "tagged" with tags that contain hyphens.

Example: let's say I have the tag foo-bar. It is linked with /tagged/foo-bar (→ 404). I can find the posts with /search/foo-bar (but this is of course not ideal because it might also find posts that contain (in the body text) words similar/equal to the tag name).

I tried to encode the hyphen (/tagged/foo%2Dbar), but no luck.

like image 234
unor Avatar asked Nov 10 '12 22:11

unor


People also ask

Can you mass change tags on Tumblr?

Tumblr has a special area called the Mass Post Editor (MPE), where you may select (and unselect) multiple published posts to add or edit tags, or delete selected posts. Open the Mass Post Editor by clicking the Mass Post Editor button on your blog's sidebar.

How do you edit all tags on Tumblr?

Click on “Edit Tags” or “Add Tags” at the top right corner. The “Edit Tags” option allows you to delete tags from posts. Make the necessary changes to your tags, then click “Remove Tags” or “Add Tags.” Your tag changes to the posts selected are now saved.


2 Answers

just for the record, because this is a popular google search: i've done it! you can use it at http://dev.goose.im/tags/.

i used a combo of PHP and jquery, basing my jquery off of a previous tumblr api script i wrote a year or two ago, and used this tumblr php oauth script for the authentication. if anyone wants me to put up the source code, i'd be happy to.

like image 95
alex baldwin Avatar answered Sep 21 '22 17:09

alex baldwin


If you aren't a programmer, how much is your time is worth to you? As they say, time is money. Not only do you have to figure out how to use the API, but choose a language and learn to write in it. That's no small task. You could higher a freelancer for $50 for an hour worth of work.

To answer your question, yes it is possible to do this with the API. It mentions "These parameters are used for /post, /post/edit and /post/reblog methods." and tags is mentioned as a string of comma separated words.

What you want to do is get a listing of every single blog post using the /posts method. You'll want to look at the "Request" section to figure out the criteria to pass to this URL. You want it to be as general as possible to get a complete listing of all your posts.

After you get a listing of posts you'll want to iterate over it and modify the tags parameter provided in the response for each post. You'll want to use the id paramater along with /post/edit, which again takes tags as a string.

The simplest language you can use for this task is PHP. You'll want to look at the curl extension to make your requests. You'll want to read up on arrays as you'll be using them a lot. You'll also need to look at explode, implode, str_replace (for the dashes), and foreach for iterating over the result.

When you do this I would highly recommend you use break at the end of your foreach loop so it only affects one post at first. Testing it first will be important, as you don't want to accidentally erase your tags/posts. print and var_dump are good ways to help you debug the code. xdebug is a nice extension that allows you to step through the code line by line as it runs. Netbeans is an IDE that has good xdebug support.

There's also a nice page here to get you started with PHP. You'll need to install PHP on your machine. You don't need to install a web server - for this PHP-CLI (command line) sapi is good enough.

like image 20
Luke Avatar answered Sep 22 '22 17:09

Luke