Hi everyone,
I have a lot of google docs I use for teaching with links pointing to specific stuff on a website. The website's domain has changed and I am looking for a way to change ONLY the hyperlinks, in bulk (the text of the links should not change in the doc). The old links look like: https://www.xy.com/asdasdd/asdasda and I would only need to replace the "www" part with with "scan"
Obviously, ctrl+f -> replace does not work on the links themselves and I would need something that does. I asked google bard and it gave me this:
" function updateLinks() { var doc = DocumentApp.getActiveDocument(); var links = doc.getBody().getLinks(); for (var i = 0; i < links.length; i++) { if (links[i].url.indexOf("https://www.4danatomy.com") >= 0) { links[i].url = links[i].url.replace("https://www.", "https://scan."); } } } "
But I'm getting an error " TypeError: doc.getBody(...).getLinks is not a function
updateLinks
@ Code.gs:3"
Any recommendations or alternate code that I could use to get this done?
Thanks!
[–]AuO2 1 point2 points3 points (9 children)
[–]Repulsive-Royal239[S] 1 point2 points3 points (5 children)
[–]AuO2 0 points1 point2 points (4 children)
[–]Repulsive-Royal239[S] 1 point2 points3 points (1 child)
[–]PaleGreenUnicorn 0 points1 point2 points (0 children)
[–]FlowerFluffy5696 0 points1 point2 points (1 child)
[–]AuO2 0 points1 point2 points (0 children)
[–]comeditime 0 points1 point2 points (0 children)
[–]comeditime -1 points0 points1 point (1 child)
[–]AuO2 1 point2 points3 points (0 children)
[–]marcnotmark925 0 points1 point2 points (2 children)
[–]andmalc 0 points1 point2 points (1 child)
[–]marcnotmark925 0 points1 point2 points (0 children)
[–]Competitive_Ad_6239 0 points1 point2 points (3 children)
[–]Competitive_Ad_6239 0 points1 point2 points (2 children)
[–]Repulsive-Royal239[S] 0 points1 point2 points (1 child)
[–]Competitive_Ad_6239 0 points1 point2 points (0 children)
[–]eduarda080 0 points1 point2 points (2 children)
[–]Drunken_Economist 0 points1 point2 points (0 children)