---
# System prepended metadata

title: 快速建立 Google Drive 圖片的 MD 連結
tags: [其他]

---

---
title: 快速建立 Google Drive 圖片的 MD 連結
tags: 其他
---

```python=
import clipboard as cp
while True:
    print("Paste the URL or press n to leave ...")
    RawData = input()
    if RawData == 'n':
        break
    URLs = RawData.split(", ")
    index = 0
    Link = ""
    for x in URLs:
        index += 1
        start = x.find('/d/')
        end = x.find('/view')
    # Exception only occurs when there's one input.
    # If there's no any accident
        if start == -1 or end == -1:
            print(f"Processing Failure at the {index} url\n")
            continue
        ID = x[3+start:end]
        Link += f'![](https://drive.google.com/uc?id={ID}&export=download)\n\r'
    cp.copy(Link)
    print(f"there are {index} URLs")
```
