Skip to content

Instantly share code, notes, and snippets.

@compor
Created February 25, 2013 15:24
Show Gist options
  • Select an option

  • Save compor/5030565 to your computer and use it in GitHub Desktop.

Select an option

Save compor/5030565 to your computer and use it in GitHub Desktop.
convert delicious tags from space-separated to comma-separated
# delicious decided (out of nowhere) to change its tag separator from whitespace to comma,
# but since it didn't update it's browser plugin, i ended up with messed up multi-word tags
# here's my quick solution to fix that mess :
#
# 1] export all your delicious tags to a html file e.g. delicious.html
# 2] execute the below awk script to the exported file
BEGIN{ FS = "=" }
{
i = 1;
while( i <= NF ) {
if( $i ~ /TAGS/ ) {
printf( "%s%s", $i, FS )
n = split( $(i + 1), a, "\"" )
# the second element of the split array should contain the tags
gsub( " ", ",", a[ 2 ] )
# print the comma separated tags
printf( "\"%s\"", a[ 2 ] )
# reconstruct the rest of split array along with the split character
# do not add the split character after the last element of the array
for( j = 3; j <= n; j++ ) {
printf( "%s%s", a[ j ], ( j != n ) ? "\"" : "" )
}
# skip the next record since we have just processed it
i++
}
else {
# if it's the last field do not use FS
printf( "%s%s", $i, ( i != NF ) ? FS : "" )
}
i++
}
printf( "%s", ORS )
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment