0

I am working with a lot of URL links which I need to decode. I want to write a macro (or use any other method, really, whatever is easiest) attached to a keyboard shortcut which will automatically decode the urls into readable text. For example, I want to press CTRL+A and have the result be that all %20 instances are replaced with a space, all & are replaced with an ENTER (\n, going down one row), all %27 replaced with ', etc.

Is there a way to accomplish this in Notepad++? So far I have been manually changing at least 2-3 codes each time, but it's maddening as I have hundreds of such URLs to work with. The URLs are sent to me automatically one at a time by a "report broken link" function and arrive as an openURL, example attached below.

Thank you!

URL examples:

ctx_ver=Z39.88-2004&ctx_enc=info%3Aofi%2Fenc%3AUTF-8&url_ver=Z39.88-2004&rfr_id=info%3Asid%2FElsevier%3ASD&svc_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Asch_svc&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&rft.aulast=GILABERTE&rft.auinit=Y&rft.date=2014&rft.issn=00017310&rft.volume=105&rft.issue=3&rft.spage=253&rft.epage=262&rft.title=Actas%20Dermo-Sifiliogr%C3%A1ficas&rft.atitle=Realidades%20y%20retos%20de%20la%20fotoprotecci%C3%B3n%20en%20la%20infancia&rft_id=info%3Adoi%2F10.1016%2Fj.ad.2013.05.004

And this is how it looks like after changing & and %20:

ctx_ver=Z39.88-2004
ctx_enc=info%3Aofi%2Fenc%3AUTF-8
url_ver=Z39.88-2004
rfr_id=info%3Asid%2FElsevier%3ASD
svc_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Asch_svc
rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal
rft.aulast=GILABERTE
rft.auinit=Y
rft.date=2014
rft.issn=00017310
rft.volume=105
rft.issue=3
rft.spage=253
rft.epage=262
rft.title=Actas Dermo-Sifiliogr%C3%A1ficas
rft.atitle=Realidades y retos de la fotoprotecci%C3%B3n en la infancia
rft_id=info%3Adoi%2F10.1016%2Fj.ad.2013.05.004

As you can see this is much more readable for extracting details, but there are still many more codes in there that need changing.

Nimrod Yanai
  • 777
  • 2
  • 8
  • 30

1 Answers1

2

Lets say you have your single URL or some more in a text file line by line you'd go through following steps:

  • Ctrl+A
  • Plugins > MIME Tools > URL Decode
  • Ctrl+H
  • Find what: &
  • Replace with: \n
  • Search mode: Regular expression
  • Click on Replace All

If you really need a shortcut like e.g. Ctrl+Alt+A you may use:

Macro > Start Recording the steps from above and Save Currently Recorded Macro when finished.

The snaps below show your sample source and the resulting text.

enter image description here

enter image description here

help-info.de
  • 6,695
  • 16
  • 39
  • 41
  • That's what I do (though I reach this menu by simply using CTRL+F and choosing the replace tab). But I'll try the MACRO and see if that works. If so I'll mark this as the answer :) Thanx! – Nimrod Yanai Mar 22 '16 at 11:53
  • Well I've recorded the macro and saved it, and it seems to work great! – Nimrod Yanai Mar 22 '16 at 12:02
  • CTRL+H is because the replace tab is simply selected in one step - but this depends on the user preference. – help-info.de Mar 22 '16 at 12:46
  • Just an update - for some reason, the macro recording doesn't record the URL decoding command. What I did was, unfortunately, record all the commands by hand via find&replace, then saved the macro with a shortcut. I don't know why the URL decoding isn't recorded. – Nimrod Yanai Mar 29 '16 at 12:35