全部 新建

user:thomas 由使用者建立的 Gists

title:mygist Gists 的標題

filename:myfile.txt Gists 的檔案名稱

extension:yml Gists 的副檔名

language:go Gists 的程式語言

topic:homelab gists with given topic

登錄


全部 新建 登錄

All gists matching topic directory

倒序排序 創建
順序排序 創建
倒序排序 更新
順序排序 更新

timmy / 使用 shutil 進行檔案與目錄操作

0 喜歡
0 分支
1 檔案
最後活躍 1 year ago
shutil 模組提供高級的檔案與目錄管理功能,包括複製、移動、壓縮與刪除,適用於備份、部署與自動化檔案管理。
automation backup directory file-management python shutil
1 import shutil
2 import os
3
4 # 定義來源與目標
5 source_file = "example.txt"
6 destination_dir = "backup/"
7 destination_file = os.path.join(destination_dir, source_file)
8
9 # 確保目標目錄存在
10 os.makedirs(destination_dir, exist_ok=True)

timmy / Mac iCloud 目錄自動切換腳本

0 喜歡
0 分支
1 檔案
最後活躍 1 year ago
這段腳本切換到使用者的 iCloud Drive 目錄 (Mobile Documents/com~apple~CloudDocs),確認目錄存在後切換到該目錄,並輸出當前工作目錄位置。
automation bash directory icloud macos script
1 #!/bin/bash
2
3 BASE_DIR="$HOME/Library/Mobile Documents/com~apple~CloudDocs"
4
5 # 確認目錄是否存在
6 if [ -d "$BASE_DIR" ]; then
7 echo "切換到目標目錄: $BASE_DIR"
8 cd "$BASE_DIR" || { echo "無法進入目標目錄,退出腳本。"; exit 1; }
9 fi
上一頁 下一頁

由 Opengist 提供支持 ⋅ Load: 302ms⋅

繁體中文
Čeština Deutsch English Español Français Magyar Italiano 日本語 Polski Português Русский Türkçe Українська 中文 繁體中文