當使用者請求檔案整理協助時:
- 了解範圍
詢問澄清問題:
- 哪個目錄需要整理?(下載、文件、整個主資料夾?)
- 主要問題是什麼?(找不到東西、重複項目、太混亂、沒有結構?)
- 是否有要避免的檔案或資料夾?(目前專案、敏感資料?)
- 要以多積極的方式整理?(保守 vs. 全面清理)
- 分析現有狀態
檢視目標目錄:
```bash
# Get overview of current structure
ls -la [target_directory]
# Check file types and sizes
find [target_directory] -type f -exec file {} \; | head -20
# Identify largest files
du -sh [target_directory]/* | sort -rh | head -20
# Count file types
find [target_directory] -type f | sed 's/.*\.//' | sort | uniq -c | sort -rn
```
總結發現:
- 總檔案和資料夾數
- 檔案類型分解
- 大小分佈
- 日期範圍
- 明顯的組織問題
- 識別組織模式
根據檔案,確定合理的分組:
按類型:
- 文件(PDF、DOCX、TXT)
- 圖片(JPG、PNG、SVG)
- 影片(MP4、MOV)
- 壓縮檔(ZIP、TAR、DMG)
- 程式碼/專案(包含程式碼的目錄)
- 試算表(XLSX、CSV)
- 簡報(PPTX、KEY)
按目的:
- 工作 vs. 個人
- 活動中 vs. 封存
- 專案特定
- 參考資料
- 臨時/草稿檔案
按日期:
- 當前年/月
- 前幾年
- 非常舊(封存候選)
- 尋找重複項目
When requested, search for duplicates:
```bash
# Find exact duplicates by hash
find [directory] -type f -exec md5 {} \; | sort | uniq -d
# Find files with same name
find [directory] -type f -printf '%f\n' | sort | uniq -d
# Find similar-sized files
find [directory] -type f -printf '%s %p\n' | sort -n
```
對於每組重複項目:
- 顯示所有檔案路徑
- 顯示大小和修改日期
- 建議保留哪個(通常是最新的或命名最佳的)
- 重要:刪除前始終要求確認
- 提議整理計畫
在進行變更前提出清晰的計畫:
```markdown
# Organization Plan for [Directory]
## Current State
- X files across Y folders
- [Size] total
- File types: [breakdown]
- Issues: [list problems]
## Proposed Structure
```
[Directory]/
├── Work/
│ ├── Projects/
│ ├── Documents/
│ └── Archive/
├── Personal/
│ ├── Photos/
│ ├── Documents/
│ └── Media/
└── Downloads/
├── To-Sort/
└── Archive/
```
## Changes I'll Make
1. Create new folders: [list]
2. Move files:
- X PDFs → Work/Documents/
- Y images → Personal/Photos/
- Z old files → Archive/
3. Rename files: [any renaming patterns]
4. Delete: [duplicates or trash files]
## Files Needing Your Decision
- [List any files you're unsure about]
Ready to proceed? (yes/no/modify)
```
- 執行整理
獲得批准後,系統化地整理:
```bash
# 建立資料夾結構
mkdir -p "path/to/new/folders"
# 移動檔案並清楚記錄
mv "old/path/file.pdf" "new/path/file.pdf"
# 使用一致的模式重新命名檔案
# 範例:「YYYY-MM-DD - Description.ext」
```
重要規則:
- 刪除任何內容前始終確認
- 記錄所有移動以便可能的復原
- 保留原始修改日期
- 優雅地處理檔案名稱衝突
- 遇到意外情況時停止並詢問
- 提供摘要和維護提示
整理後:
```markdown
# Organization Complete! ✨
## What Changed
- Created [X] new folders
- Organized [Y] files
- Freed [Z] GB by removing duplicates
- Archived [W] old files
## New Structure
[Show the new folder tree]
## Maintenance Tips
To keep this organized:
1. Weekly: Sort new downloads
2. Monthly: Review and archive completed projects
3. Quarterly: Check for new duplicates
4. Yearly: Archive old files
## Quick Commands for You
```bash
# Find files modified this week
find . -type f -mtime -7
# Sort downloads by type
[custom command for their setup]
# Find duplicates
[custom command]
```
Want to organize another folder?
```