命令列工具
tfile 讓你在終端機處理檔案,適合指令碼、備份和 AI Agent。它用 API 權杖登入,能做的事以權杖和你的帳號權限為限。
安裝
每個版本都附上各系統的程式。下載符合你系統的檔案:
| 系統 | 檔案 |
|---|---|
| Linux (x86-64) | tfile-<version>-linux-amd64 |
| Linux (ARM64) | tfile-<version>-linux-arm64 |
| macOS (Apple silicon) | tfile-<version>-macos-arm64 |
| macOS (Intel) | tfile-<version>-macos-amd64 |
| Windows (x86-64) | tfile-<version>-windows-amd64.exe |
在 Linux 上先核對下載的檔案,設為可執行,再放到終端機找得到的位置。macOS 請改用 shasum -a 256 -c --ignore-missing SHA256SUMS 核對。
sha256sum -c --ignore-missing SHA256SUMS
chmod +x tfile-1.5.0-linux-amd64
sudo mv tfile-1.5.0-linux-amd64 /usr/local/bin/tfile
tfile --version在 Windows 上,把檔案改名為 tfile.exe,放到 PATH 裡的資料夾。
所有程式都由 GitHub Actions 建置,可以驗證來源:
gh attestation verify tfile-1.5.0-linux-amd64 -R ThirtyFile/ThirtyFilexattr -d com.apple.quarantine tfile。Windows SmartScreen 可能跳出警告:選擇其他資訊 › 仍要執行。登入
執行 tfile auth login,它會在瀏覽器中開啟一個帶有代碼的網址。照常登入(密碼、兩步驟驗證、密碼金鑰或單一登入),確認頁面顯示的是同一個代碼,選擇 tfile 能做什麼、限定哪個資料夾、多久到期,然後核准。tfile 隨即收到它的 API 權杖。--no-browser 只顯示網址,可在另一台裝置上開啟。代碼只能用一次,十分鐘內有效。
tfile auth login --server https://drive.example.com
tfile auth whoami也可以在網頁介面帳號選單的 API 權杖中建立權杖後貼上:tfile auth login --with-token,或用管線傳入。貼上時不會顯示,權杖也不會放在指令參數裡。
指令碼和伺服器可以改用環境變數提供網址和權杖,這樣不會儲存任何資料:
export THIRTYFILE_URL=https://drive.example.com
export THIRTYFILE_TOKEN=tft_…- 網址必須是
https,只有本機(localhost)可以用http。 - 權杖只會送到一起提供的網址。不會跟隨重新導向,也不讀取任何
.env檔案。 - 也可以使用應用程式密碼(有自己的限制),但 API 權杖比較安全。
指定檔案和資料夾
- 從頂層開始的路徑:
/My files/Reports/q3.pdf。別人分享給你的在Shared with me之下。 - 相對於某個空間的路徑:用
--space或THIRTYFILE_SPACE選擇,預設是我的檔案(路徑中寫My files)。.代表空間本身。 - ID:
id:…。結果都附有 ID,改名或搬移後 ID 不變。垃圾桶裡的項目用 ID 指定。
tfile files list "/My files/Reports"
tfile files list Reports
tfile files list . --space "Team"
tfile files get id:4f2c…/ 開頭的參數會被 shell 改寫。請使用相對路徑或 ID,或設定 MSYS_NO_PATHCONV=1。指令
指令的形式像 tfile files move。可以用想做的事找指令,再查看它需要什麼:
tfile cli search "move files into a folder"
tfile schema files move
tfile files move --help常見工作:
tfile files list Reports
tfile files search invoice --ext pdf
tfile files download Reports/q3.pdf --output q3.pdf
tfile files upload q3.pdf summary.md Reports
tfile files upload ./photos Reports
tfile files folders create "Reports/2026"
tfile files move Reports/q3.pdf Archive
tfile files rename id:4f2c… "q3 final.pdf"
tfile files archive create Reports Archive
tfile files versions list Reports/q3.pdf
tfile files trash Reports/old.txt --force
tfile trash list
tfile trash restore id:4f2c…
tfile files text get Reports/q3.docxfiles text get回傳為檔案內搜尋從文件讀出的文字(需管理員開啟檔案內搜尋),代理不必下載、開啟檔案就能讀取內容。- 使用限定在一個資料夾的權杖時,相對路徑從該資料夾開始(
tfile files list .列出它的內容),找不到資料夾以外的任何東西。 files download下載資料夾時會存成 ZIP 檔。files upload可以上傳檔案和資料夾。資料夾會連同裡面的內容一起上傳(連結和空資料夾除外)。連線中斷時會自動續傳;指令中途停下時,再執行一次同樣的指令即可,已送達的部分不會重複上傳。只要檔案沒有變動,一週內都能這樣續傳。tfile mcp讓 AI 工具透過 MCP 處理你的檔案:請見 AI Agent。- 指令來自伺服器的 API 說明,登入時儲存。伺服器更新後,執行
tfile auth whoami取得新指令。
按 Tab 鍵補完
tfile complete 會依你登入的伺服器的指令,輸出 bash、zsh、fish、PowerShell 或 elvish 的補完腳本。在 shell 的啟動檔中載入它;伺服器更新後重新產生。
# bash (~/.bashrc)
source <(tfile complete bash)
# zsh (~/.zshrc)
source <(tfile complete zsh)
# fish
tfile complete fish > ~/.config/fish/completions/tfile.fish
# PowerShell ($PROFILE)
tfile complete powershell | Out-String | Invoke-Expression
安全地變更
--dry-run只顯示要求,不會送出。- 會拿走東西的變更會先詢問;在指令碼中沒有加
--force就不執行。 - 名稱已被使用時會拒絕。用
--on-conflict keep(兩個都保留)或replace(取代)決定。 --if-version只在檔案仍是你讀到的版本(updated_at)時儲存新內容。- 耗時的工作會追蹤到完成。
--no-wait立即返回,之後用tfile jobs wait追蹤。
tfile files move Reports/q3.pdf Archive --dry-run
tfile files upload q3.pdf Reports --on-conflict keep
tfile files content update Reports/notes.txt notes.txt --if-version 1790000000管理員的權杖若有檢視管理(admin.read)就能讀取它:tfile users list、tfile settings get、tfile logs sign-ins list、tfile usage get、tfile storage list、tfile backups list,以及 tfile cli search 找得到的其他指令。這種權杖最長有效 90 天,不能限定在資料夾內,帳號不再是管理員時就會失效;密碼、金鑰等機密不會出現在回應中。列出備份或儲存位置裡的內容(tfile backups snapshots browse、tfile storage objects list)和下面這些操作一樣要等你核准。有此權限的權杖要分享(tfile shares、access、buckets、ftp-folders)、永久刪除或清空垃圾桶時,會等你在瀏覽器中核准:tfile 顯示網址並等到你核准或拒絕,再顯示結果。--no-wait 會立即顯示核准要求,之後可用 tfile approvals wait <id> 追蹤。--force 不會略過核准。
有管理(admin.users、admin.spaces、admin.storage 和 admin.settings)的管理員權杖還能變更控制台。可以復原的變更會立即執行:tfile spaces create、tfile branding update、tfile storage test、tfile moves pause。其他變更和分享一樣要等你核准,核准頁面會寫出它涉及的帳號、空間或儲存位置:tfile users create、tfile users update、tfile groups update、tfile settings update、tfile storage update、tfile backups policies create。只有本人能在網頁介面做的操作,例如電子郵件設定、單一登入或新增儲存位置,不是指令:tfile cli search 和 tfile schema 找得到它,並寫明 browser only 和原因;直接輸入會以 browser_only 失敗。只有本人能送出的欄位,例如帳號的密碼或角色,會以 browser_only_field 拒絕;tfile schema 在 browser_only_fields 列出這些欄位。
tfile users create amy --display-name "Amy Chen"
tfile cli search "change the email server"
輸出和結束碼
結果以 JSON 寫到標準輸出,訊息和錯誤寫到標準錯誤。清單的格式是 {"items": […], "next": …},每頁 50 筆。搜尋也一頁一頁回傳。
tfile files list Reports --limit 20
tfile files list Reports --limit 20 --cursor "…"
tfile files list Reports --all錯誤的格式是 {"error": {"code": …, "message": …}},結束碼表示錯誤的類型:
| 結束碼 | 意義 |
|---|---|
0 | 成功 |
1 | 其他失敗,或你選擇不執行 |
2 | 指令或參數錯誤 |
3 | 未登入,或權杖已失效 |
4 | 找不到,或你的帳號看不到 |
5 | 權限不足 |
6 | 名稱已被使用,或期間有變動 |
7 | 稍後再試 |
9 | 只完成一部分 |
10 | 需要 --force |
錯誤的 code 比結束碼更詳細,而且各版本之間不變。常見的有:
| 代碼 | 結束碼 | 意思 |
|---|---|---|
name_taken | 6 | 那裡已有同名項目 |
version_conflict | 6 | 檔案已不是 --if-version 指定的版本 |
not_empty | 6 | 資料夾不是空的 |
busy | 7 | 項目還在變更中 |
space_moving | 7 | 空間正在搬到其他儲存位置 |
storage_unavailable | 7 | 磁碟或儲存服務沒有回應 |
read_only | 5 | 空間是唯讀的 |
token_permission | 5 | API 權杖缺少權限 |
token_folder | 5 | 權杖限定在一個資料夾:超出範圍,或是資料夾本身 |
token_folder_gone | 3 | 權杖的資料夾已不存在,或帳號已無法開啟它 |
token_not_admin | 3 | 管理用的權杖,其帳號已不是管理員 |
browser_only | 5 | 只有本人能在網頁介面做這件事 |
browser_only_field | 5 | 只有本人能在網頁介面送出的欄位(密碼、角色、憑證) |
approval_refused | 5 | 在瀏覽器中被拒絕:沒有任何變更 |
approval_expired | 7 | 十分鐘內無人核准 |
approval_failed | 1 | 已核准但沒有執行(它指定的項目在這期間有變動) |
too_many_approvals | 7 | 這個權杖已有五個核准要求在等待 |
too_many_items | 2 | 超過一次請求能處理的項目數 |
content_search_off | 6 | 檔案內搜尋已關閉 |
設定檔
設定檔儲存一組伺服器和權杖。可以為不同伺服器或權杖建立多個,並綁定到資料夾:
tfile auth create work --server https://drive.example.com
tfile auth activate work ~/projects/reports
tfile auth list
tfile files list --profile work- 指令依序使用:
THIRTYFILE_TOKEN(搭配THIRTYFILE_URL)、--profile、THIRTYFILE_PROFILE、目前資料夾綁定的設定檔、預設設定檔。 - 設定檔放在
~/.config/tfile(Linux)、~/Library/Application Support/tfile(macOS)或%APPDATA%\tfile(Windows),可用THIRTYFILE_CONFIG_DIR更改。權杖存在只有你能讀取的檔案中,沒有加密(用--use-keyring登入時除外)。 tfile auth login --use-keyring會把權杖改存到系統鑰匙圈:macOS 用鑰匙圈,Windows 用認證管理員,Linux 透過secret-tool程式(套件libsecret-tools)使用 Secret Service(GNOME Keyring、KWallet)。之後再登入也會存在那裡;--no-use-keyring可改回檔案。tfile auth whoami會顯示存放位置。tfile auth logout會在伺服器上停用 API 權杖,並從這台電腦清除。應用程式密碼只會在這裡清除,請到網頁介面移除。
單一使用者模式
單一使用者模式沒有權杖:
tfile auth login --server http://localhost:8080 --no-tokenTHIRTYFILE_KEEP_HISTORY=false 時沒有垃圾桶:tfile files trash 會永久刪除。