Skip to content

Instantly share code, notes, and snippets.

@BitionSong
Forked from Luoyayu/bear_autosave.scpt
Created February 8, 2020 08:46
Show Gist options
  • Save BitionSong/f91d9656251e0c2fbecb1842dde39fb1 to your computer and use it in GitHub Desktop.
Save BitionSong/f91d9656251e0c2fbecb1842dde39fb1 to your computer and use it in GitHub Desktop.
Bear writer: autosave to icloud
tell application "System Events"
-- 前提/premiss:
-- 1. 在iCloud云盘下新建Bear文件夹/Create a new folder "Bear" under the iCloud
-- 2. 在Bear下手动备份一次,文件->备份笔记->选中Bear文件夹/Manually back up once under Bear APP, File -> Backup Notes -> Select "Bear" folder in iCloud
-- 脚本做的事:/What the script does:
-- 1. 删除已有备份/Delete existing backup
-- 2. 自动化点击/Automated click
tell application "Finder" to activate -- 打开Finder/Open Finder
key code 34 using {shift down, command down} -- ⇧+⌘+I 进入iCloud/Enter in iCloud
do shell script "cd ~;cd 'Library/Mobile Documents/com~apple~CloudDocs/Bear/';rm B*" -- 删除已有备份/Delete existing backup
key code 13 using {command down} -- ⌘+W
delay 1
tell application "Bear" to activate -- 打开Bear/Open Bear APP
tell process "Bear"
set frontmost to true -- 置于前台/At the front desk
click menu item "备份笔记..." of menu "文件" of menu bar item "文件" of menu bar 1 -- 点击文件->备份笔记
click button "导出笔记" of window "请选择保存笔记的位置"
key code 13 using {command down} -- ⌘+W
end tell
tell application "Finder" to activate
key code 13 using {command down} -- ⌘+W
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment