2023-12-29|閱讀時間 ‧ 約 27 分鐘

100篇文章輕鬆整合 | Obsidian x Notion

我喜歡閱讀,也喜歡在讀完後分享心得。我將閱讀心得分享在《閱讀茉莉》這個 podcast 上,也會在Vocus 或Medium分享文字作品。


我大部分都是利用 Notion 或 Obsidian平台來寫作。這兩個平台的好處是它們都支持 MD 格式,所以可以互通使用。因為各有優缺點,所以我平時會在這兩個平台間互相參照使用。


日積月累之下,我的寫作資料庫越來越多。我發現必須開始進行某些程度的整合。今天想要與大家分享最近整合如何將這100集的文章從Notion 或 Obsidian這二個平台做整合。


或許你和我一樣,也在利用 Notion 或者 Obsidian進行整合。如果是這樣,你可能需要一些方法來快速地整合你的文稿,而不必花太多時間在每天的設定上。這樣你就能專注於閱讀和寫作,其他的事情就交給這些系統來處理。


從NOTION 抓取資料&檔名

(如果你只想要抓取檔名只要用這個方法就可以,如果你還想要抓取檔案的內容,那就要到下一步)

從NOTION download 全部資料檔。

(這個動作基本上已經可以幫你抓取全部的資料檔,還有用Excel抓出全部的檔名。)

download好了之後,會有Excel檔的檔名list放在一張spreadsheet。檔案內容則會用MD檔的方式呈現:


接下來到你的Obsidian Vault找到你要整合的檔案。

或許你已經有發現Obsidian的檔案前面都不是用"#"。因為Obsidian,無法接受"#"的符號當heading,所以,我改用"EP"來區分。


所以,我們只要用"replace",就可以將2個Excel資料檔整合在一起。取決於你要以哪一個平台為主做整合。

檔案的整合

至於檔案的整合,我用python 轉檔。以下是用notion的檔案合併到Obsidian。

以下是的邏輯概念是:

1) replacing "#" with "EP"

2) 移除掉Notion自動生成".md"之前的一串數列。ex "#1 7大升級軟體改變負面情緒模式 bee64592ae98481bbe9f51bce81c61ae.md"

import os
import re

def rename_files(directory_path):
for filename in os.listdir(directory_path):
if "#" in filename and ".md" in filename:
# Replace "#" with "EP" and add underscore after each number
new_filename = re.sub(r'#(\d+)', lambda match: f'EP{match.group(1)}_', filename)

# Remove words between ".md" and the space before ".md"
index_md = new_filename.rfind(".md")
if index_md != -1:
space_before_md = new_filename.rfind(" ", 0, index_md)
if space_before_md != -1:
new_filename = new_filename[:space_before_md] + new_filename[index_md:]

# Rename the file
os.rename(os.path.join(directory_path, filename), os.path.join(directory_path, new_filename))
print(f'Renamed: {filename} to {new_filename}')

# Replace 'your_directory_path' with the actual path to your directory
directory_path = r'your_directory_path'
rename_files(directory_path)


文件修改之後會是長這樣:


這些修改好的文件就跟我Obsidian裡面的文件格式詳符合了。

修改完之後的新的檔名,會成為Obsidian裡面的heading。


成功修改完畢!


相反的,如果你想用Obsidian的資料導入整合到Notion也是一樣的做法。

用Obsidian的資料導入整合到Notion

在Notion介面"import"檔案:

選"Text & Markdown"

最後, import 進來的檔案都會在被新到一個新的folder.




希望今天的分享能幫助熱愛寫作的人盡情寫作,別再為資料整合和轉檔的事情煩惱。現在科技進步超快,處理這些技術問題已經變得很方便。最重要的是,多花點時間寫作和思考,因為這才是人類真正有價值的部分喔!


分享至
成為作者繼續創作的動力吧!
這裡是您找尋實用軟體工具🛠️的地方。從Podcast創作到日常寫作,或是資料整理或家庭財務應用,我將在這裡分享那些幫助您事半功倍、提高效率的好用工具,讓您輕鬆應對生活或工作中的不同挑戰。
從 Google News 追蹤更多 vocus 的最新精選內容從 Google News 追蹤更多 vocus 的最新精選內容

發表回應

成為會員 後即可發表留言