Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

qqurioustiger8945

macrumors regular
Original poster
Mar 9, 2017
115
2
Hey everyone,

The following example is entirely hypothetical.

Let's say I keep a large list of historical events in a rich-text document with the following pattern:

*Historical event* | YouTube video 1 | YouTube video 2 | ...

Inside each of the "YouTube video" phrases is a hyperlink that redirects me to the equivalent YouTube video.

If, for whatever reason, I wished to mass edit those links
[1] and at the same time, the links were not inside those phrases, but instead right next to them in simple text form[2], I could easily hit Find "www.youtube.com/watch?v=" and Replace All with "youtu.be/"

Or Find "www.youtube" and Replace All with "m.youtube", and it would be fine after that.

However since the links are inside the phrases, I cannot do a simple Find/Replace, and as I said the list is very large, so I cannot possibly go through each one of them to manually change it.

Is there an automated process that would do this for me? Maybe a script, or something with the app Automator?

Note that currently the document itself is an RTF file and I use TextEdit and Microsoft Word for Mac. I am of course willing to convert the document into another format, or use another app for this matter.

Again, it's obvious there's no reason to convert links to their shortened versions, but this was just an example, just in order to get an idea of the process that I need to put in use for several other purposes in the future.

Please suggest solutions or alternatives. Thank you in advance. :)


__________________________________________________

Footnotes
Please, ignore the space after "https://"

1. e.g., from https:// www.youtube.com/watch?v=A1B2C3D4E5F
to YouTube's shortened URL https:// youtu.be/A1B2C3D4E5F
or YouTube's mobile site https:// m.youtube.com/watch?v=A1B2C3D4E5F


2. e.g., YouTube video 1
https:// www.youtube.com/watch?v=A1B2C3D4E5F
 

cruisin

macrumors 6502a
Apr 1, 2014
962
223
Canada
TextEdit is too feature rich, as it interprets RTF as a document (fonts and hyperlinks display normally). What you need is something that is more basic, which will show you the structure of the raw hyperlink. In Windows I used Notepad or Notepad++ but for Mac I use TextWrangler. You can use whatever you want, but it cannot show hyperlinks as blue words.

Opening RTF in something basic will show a lot more text that is usually hidden (controls formatting), but you can find/replace from hyperlinks as usual (they are just text now). Make a backup before editing a file in this way, in case you replace more than expected, as there is no safety net and you can delete as much as you want without the app complaining (it assumes that you know what you are doing).
 
  • Like
Reactions: qqurioustiger8945

qqurioustiger8945

macrumors regular
Original poster
Mar 9, 2017
115
2
TextEdit is too feature rich, as it interprets RTF as a document (fonts and hyperlinks display normally). What you need is something that is more basic, which will show you the structure of the raw hyperlink. In Windows I used Notepad or Notepad++ but for Mac I use TextWrangler. You can use whatever you want, but it cannot show hyperlinks as blue words.

Opening RTF in something basic will show a lot more text that is usually hidden (controls formatting), but you can find/replace from hyperlinks as usual (they are just text now). Make a backup before editing a file in this way, in case you replace more than expected, as there is no safety net and you can delete as much as you want without the app complaining (it assumes that you know what you are doing).

Thank you for your response.

I will give TextWrangler a try. If I got it right, it can basically display my RTF document in its non-rich text form; sort of like when one previews a thread they're about to make, in either html-rich form or text-only form, where all code included is shown.

e.g., This sentence will be in bold.
[b ]This sentence will be in bold.[ /b] (Ignore the spaces)

Did I get it right?
 

cruisin

macrumors 6502a
Apr 1, 2014
962
223
Canada
You got it right.

For example:
Code:
to YouTube's shortened URL https://youtu.be/A1B2C3D4E5F
Becomes (using Word RTF output in textWrangler):
Code:
\par \hich\af31506\dbch\af31505\loch\f31506 to YouTube's shortened URL }{\field{\*\fldinst {\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid5010322 \hich\af31506\dbch\af31505\loch\f31506  \hich\af31506\dbch\af31505\loch\f31506 HYPERLINK
\hich\af31506\dbch\af31505\loch\f31506 "}{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid5010322\charrsid5010322 \hich\af31506\dbch\af31505\loch\f31506 https://\hich\af31506\dbch\af31505\loch\f31506 youtu.be/A1B2C3D4E5}{\rtlch\fcs1 \af31507 \ltrch\fcs0
\insrsid5010322 \hich\af31506\dbch\af31505\loch\f31506 F}{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid5010322 \hich\af31506\dbch\af31505\loch\f31506 "\hich\af31506\dbch\af31505\loch\f31506  }}{\fldrslt {\rtlch\fcs1 \af31507 \ltrch\fcs0
\cs15\ul\cf19\insrsid5010322\charrsid1007526 \hich\af31506\dbch\af31505\loch\f31506 https://\hich\af31506\dbch\af31505\loch\f31506 youtu.be/A1B2C3D4E5F}}}\sectd \ltrsect
\linex0\headery708\footery708\colsx708\endnhere\sectlinegrid400\sectdefaultcl\sectrsid999918\sftnbj {\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid5010322
\par }{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid5010322
Lots of additional stuff, but editing the URL is possible and worked in the test I did.
 
  • Like
Reactions: qqurioustiger8945

qqurioustiger8945

macrumors regular
Original poster
Mar 9, 2017
115
2
You got it right.

For example:
Code:
to YouTube's shortened URL https://youtu.be/A1B2C3D4E5F
Becomes (using Word RTF output in textWrangler):
Code:
\par \hich\af31506\dbch\af31505\loch\f31506 to YouTube's shortened URL }{\field{\*\fldinst {\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid5010322 \hich\af31506\dbch\af31505\loch\f31506  \hich\af31506\dbch\af31505\loch\f31506 HYPERLINK
\hich\af31506\dbch\af31505\loch\f31506 "}{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid5010322\charrsid5010322 \hich\af31506\dbch\af31505\loch\f31506 https://\hich\af31506\dbch\af31505\loch\f31506 youtu.be/A1B2C3D4E5}{\rtlch\fcs1 \af31507 \ltrch\fcs0
\insrsid5010322 \hich\af31506\dbch\af31505\loch\f31506 F}{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid5010322 \hich\af31506\dbch\af31505\loch\f31506 "\hich\af31506\dbch\af31505\loch\f31506  }}{\fldrslt {\rtlch\fcs1 \af31507 \ltrch\fcs0
\cs15\ul\cf19\insrsid5010322\charrsid1007526 \hich\af31506\dbch\af31505\loch\f31506 https://\hich\af31506\dbch\af31505\loch\f31506 youtu.be/A1B2C3D4E5F}}}\sectd \ltrsect
\linex0\headery708\footery708\colsx708\endnhere\sectlinegrid400\sectdefaultcl\sectrsid999918\sftnbj {\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid5010322
\par }{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid5010322
Lots of additional stuff, but editing the URL is possible and worked in the test I did.

Thank you very much. :)
 

qqurioustiger8945

macrumors regular
Original poster
Mar 9, 2017
115
2
You got it right.

By the way, I just started using TextWrangler and it's fine, but unfortunately it doesn't support RTFD or DOCX.

You don't, by any chance, know of some other app that supports RTFD or DOCX? :confused:

Again, thank you.
 

cruisin

macrumors 6502a
Apr 1, 2014
962
223
Canada
RTFD (from TextEdit) opens fine for me, but you need to select the file with the text as the D from RTFD means directory and the RTFD "file" is a folder pretending to be a file.

DOCX is similar in that it is also a folder pretending to be a file, so you also need to find the file you need. It also opens fine with TextWrangler for me, but there are more files to sort through. Try finding the file named document.xml
 
  • Like
Reactions: qqurioustiger8945

qqurioustiger8945

macrumors regular
Original poster
Mar 9, 2017
115
2
RTFD (from TextEdit) opens fine for me, but you need to select the file with the text as the D from RTFD means directory and the RTFD "file" is a folder pretending to be a file.

DOCX is similar in that it is also a folder pretending to be a file, so you also need to find the file you need. It also opens fine with TextWrangler for me, but there are more files to sort through. Try finding the file named document.xml

Yep, you're absolutely right!

Just tested an RTFD myself, and works fine. :)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.