📁

disk-audit Skill

磁碟常態盤點/整理工具

找大檔案 最近修改 副檔名統計 重複檔偵測

讓龍蝦幫你自動盤點電腦裡的檔案!

🎯 這個 Skill 能做什麼?

1Top 大檔 - 找出佔用空間最多的檔案(預設 Top 30)

2最近修改 - 列出最近修改的檔案(Top 30)

3副檔名統計 - 統計各種副檔名的總容量(Top 30)

4重複檔偵測 - 用 SHA256 雜湊找出重複的檔案

💡 使用方式:設定好之後,只要跟龍蝦說「跑磁碟盤點」就會自動產出報告!

📂 第一步:建立 Skill 資料夾結構

在 PowerShell 執行以下指令,建立 skill 資料夾:

# 建立 skill 資料夾結構
mkdir "$env:USERPROFILE\.openclaw\workspace\skills\disk-audit\scripts" -Force

# 建立報告輸出資料夾
mkdir "$env:USERPROFILE\.openclaw\workspace\reports\disk-audit" -Force
📁 資料夾結構:
.openclaw/workspace/skills/disk-audit/ - Skill 主資料夾
.openclaw/workspace/skills/disk-audit/scripts/ - 腳本資料夾
.openclaw/workspace/reports/disk-audit/ - 報告輸出資料夾

📝 第二步:建立 SKILL.md

disk-audit 資料夾建立 SKILL.md 檔案:

# disk-audit

磁碟常態盤點/整理工具

## 功能
- 掃描指定資料夾,產出盤點報告
- 找出大檔案、最近修改、副檔名統計、重複檔

## 設定
- 掃描範圍:C:\Users\user\Downloads + C:\Users\user\Desktop
- 大檔門檻:500MB
- 排程:手動執行(說「跑磁碟盤點」)

## 使用方式
跟龍蝦說:「跑磁碟盤點」

## 報告位置
.openclaw/workspace/reports/disk-audit/YYYY-MM-DD.md
💡 提示:你可以根據需求修改掃描範圍和大檔門檻!

⚙️ 第三步:建立掃描腳本 (1/2)

scripts 資料夾建立 scan.ps1

# disk-audit scan.ps1
# 磁碟盤點掃描腳本

param(
    [string[]]$ScanPaths = @(
        "$env:USERPROFILE\Downloads",
        "$env:USERPROFILE\Desktop"
    ),
    [int]$LargeFileMB = 500,
    [int]$TopN = 30
)

$reportDate = Get-Date -Format "yyyy-MM-dd"
$reportPath = "$env:USERPROFILE\.openclaw\workspace\reports\disk-audit\$reportDate.md"

# 排除的系統資料夾
$excludeDirs = @("Windows", "Program Files", "Program Files (x86)",
                 '$Recycle.Bin', "node_modules", ".git")

Write-Host "開始掃描..." -ForegroundColor Cyan

⚙️ 第三步:建立掃描腳本 (2/2)

# 取得所有檔案
$allFiles = @()
foreach ($path in $ScanPaths) {
    if (Test-Path $path) {
        $allFiles += Get-ChildItem -Path $path -Recurse -File -ErrorAction SilentlyContinue |
            Where-Object {
                $dominated = $false
                foreach ($ex in $excludeDirs) {
                    if ($_.FullName -like "*\$ex\*") { $dominated = $true; break }
                }
                -not $dominated
            }
    }
}

# 產生報告
$report = "# 磁碟盤點報告 - $reportDate`n`n"

# Top 大檔
$report += "## Top $TopN 大檔案`n"
$largeFiles = $allFiles | Sort-Object Length -Descending | Select-Object -First $TopN
foreach ($f in $largeFiles) {
    $sizeMB = [math]::Round($f.Length / 1MB, 2)
    $report += "- $sizeMB MB - $($f.FullName)`n"
}

# 儲存報告
$report | Out-File -FilePath $reportPath -Encoding UTF8
Write-Host "報告已產生:$reportPath" -ForegroundColor Green

🔧 設定參數說明

參數說明預設值
$ScanPaths 要掃描的資料夾路徑(可多個) Downloads + Desktop
$LargeFileMB 大檔門檻(多少 MB 算大檔) 500 MB
$TopN 顯示前幾名 30
$excludeDirs 排除的資料夾 Windows, node_modules 等
⚠️ 注意:掃描全機會比較慢,建議先指定特定資料夾測試。

🚀 如何使用

方法一:直接跟龍蝦說

跑磁碟盤點

龍蝦會自動執行 scan.ps1 並產出報告。

方法二:手動執行腳本

# 在 PowerShell 執行
& "$env:USERPROFILE\.openclaw\workspace\skills\disk-audit\scripts\scan.ps1"

方法三:指定掃描路徑

# 掃描 D 槽的 Videos 資料夾
& "$env:USERPROFILE\.openclaw\workspace\skills\disk-audit\scripts\scan.ps1" `
    -ScanPaths @("D:\Videos") -LargeFileMB 1000

📊 報告範例

# 磁碟盤點報告 - 2026-02-05

## Top 30 大檔案
- 4521.32 MB - D:\Videos\movie.mkv
- 2103.45 MB - C:\Users\user\Downloads\software.iso
- 1892.11 MB - D:\Backup\archive.zip
- 856.23 MB - C:\Users\user\Desktop\presentation.pptx
...

## 最近修改 Top 30
- 2026-02-05 10:30 - C:\Users\user\Documents\report.docx
- 2026-02-05 09:15 - C:\Users\user\Downloads\data.xlsx
...

## 副檔名容量統計
| 副檔名 | 總容量 | 檔案數 |
|--------|--------|--------|
| .mkv   | 15.2 GB | 12 |
| .mp4   | 8.7 GB  | 45 |
| .zip   | 3.2 GB  | 28 |

🔍 進階功能:重複檔偵測

scan.ps1 加入以下程式碼:

# 重複檔偵測(用檔案大小分組,再用 SHA256 比對)
$report += "`n## 可能的重複檔案`n"

$sizeGroups = $allFiles | Group-Object Length | Where-Object { $_.Count -gt 1 }
$duplicates = @()

foreach ($group in $sizeGroups | Select-Object -First 50) {
    $hashes = @{}
    foreach ($file in $group.Group) {
        $hash = (Get-FileHash $file.FullName -Algorithm SHA256).Hash
        if ($hashes.ContainsKey($hash)) {
            $duplicates += [PSCustomObject]@{
                Hash = $hash
                File1 = $hashes[$hash]
                File2 = $file.FullName
                Size = $file.Length
            }
        } else {
            $hashes[$hash] = $file.FullName
        }
    }
}

foreach ($dup in $duplicates) {
    $sizeMB = [math]::Round($dup.Size / 1MB, 2)
    $report += "- [$sizeMB MB] 重複:`n"
    $report += "  - $($dup.File1)`n"
    $report += "  - $($dup.File2)`n"
}
🎉

disk-audit Skill 完成!

現在你可以跟龍蝦說「跑磁碟盤點」來產生報告了!

📋 快速複習:
1. 建立資料夾結構
2. 建立 SKILL.md 說明檔
3. 建立 scan.ps1 掃描腳本
4. 跟龍蝦說「跑磁碟盤點」
➡️ 下一個 Skill:Google Drive 上傳