简体   繁体   English

我正在寻找一种在谷歌驱动器文件中批量查找/替换超链接的方法

[英]Im looking for a way to mass find/replace hyperlinks in a google drive file

Im currently performing a migration of data from Box to Google drive.我目前正在将数据从 Box 迁移到 Google Drive。 Most of these files contain links that reference, and then take the user to, other files within the box drive.这些文件中的大多数都包含引用,然后将用户带到盒式驱动器中的其他文件的链接。

However, when i do eventually migrate the files to google drive, the old links will break and become obsolete as the previous location in Box will no longer exist.但是,当我最终将文件迁移到谷歌驱动器时,旧链接将断开并过时,因为 Box 中的先前位置将不再存在。

Writing a find/replace script that updates the strings wont work as although the string changes the URL_link attached to it stays the same, does anybody have any suggestions?编写更新字符串的查找/替换脚本将不起作用,因为尽管字符串更改了附加到它的 URL_link 保持不变,有人有任何建议吗? I can't seem to find anything about this in the google API.我似乎在 google API 中找不到任何关于此的信息。

I had the idea of breaking the link, updating the string, and then making it a link again.我的想法是断开链接,更新字符串,然后再次将其设为链接。 But once again, i can't seem to find how to create a link from a string in the API.但再一次,我似乎无法找到如何从 API 中的字符串创建链接。

Any help would be really appreciated, thanks任何帮助将不胜感激,谢谢

Solution / Workaround解决方案/变通方法

You can automate this using the Google APIs.您可以使用 Google API 自动执行此操作。 These are the following steps I would follow to achieve what you are aiming for here:这些是我将遵循的以下步骤,以实现您在这里的目标:

  1. Migrate the files to Google Drive (this will convert your documents into Google Doc files that then you can access with the Gooogle Docs API. Do this by specifying the MIME type in the metadata when doing the migration. Here you can see how to specify this and upload using the Google Drive API.将文件迁移到 Google Drive(这会将您的文档转换为 Google Doc 文件,然后您可以使用 Gooogle Docs API 访问这些文件。通过在执行迁移时在元数据中指定 MIME 类型来执行此操作。您可以在此处了解如何指定此项并使用 Google Drive API 上传。
  2. Once you have all your desired files uploaded to Drive as docs, you will get their body and look for the links in order to replace them.将所有所需文件作为文档上传到云端硬盘后,您将获得它们的正文并查找链接以替换它们。 You can access the links by accessing the body element inside the document element, for more information with regards to this check this link and explore the nested objects.您可以通过访问文档元素内的 body 元素来访问链接,有关此内容的更多信息, 请查看此链接并探索嵌套对象。 Perform a find replace on the body to change the URL of the document.对正文执行查找替换以更改文档的 URL。

If you have issues regarding the change of attached links as you mentioned in your question, check out this other Stack Overflow answer that addresses this problems.如果您对问题中提到的附加链接的更改有疑问,请查看解决此问题的其他 Stack Overflow 答案

  1. Change the link by updating the document following the instructions stated in the above Stack Overflow Question and the documentation .通过按照上述堆栈溢出问题和文档中所述的说明更新文档来更改链接。

I hope this has helped you.我希望这对你有帮助。 Let me know if you need anything else or if you did not understood something.如果您需要其他任何东西或者您不理解某些东西,请告诉我。 :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 PyDrive 替换/更新 Google Drive 上的文件? - How to replace/update a file on Google Drive with PyDrive? 如何找到谷歌驱动器的特定文件ID? - How to find a particular file id of google drive? 使用Python寻找构建简单的文件路径查找和替换程序 - Looking to a build a simple find and replace program for file paths using Python 如何通过google驱动器的链接找到文件的类型? - How do I find the type of the file through the link of the google drive? Google Drive API如何找到文件的路径? - Google Drive API How can I find the path of a file? 有没有办法从网站下载文件并将其直接上传到 Google Drive? - Is there a way to download a file from a website and upload it directly to Google Drive? 有没有办法获取 Google Drive 中文件的文件共享链接? - Is there a way to get the File Sharing Link of files in Google Drive? 有没有办法在使用 gdrive API 将文件上传到谷歌驱动器时重命名文件? - Is there a way to rename a file while uploading it to google drive using gdrive API? Google 云端硬盘更新文件 - Google Drive Update File 我试图找到一种方法来完成这项工作,它试图计算一个短语在一行一行的文本文件中出现的次数 - Im trying to find a way to make this work it is trying to counts the amount of times a phrase appears in a line by line text file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM