首页/项目/桌面整理大师
免费工具 · Windows · 纯技术分享

桌面整理大师

一个我自己写的小工具:把桌面上散落的文件交给大模型看一眼,让它告诉你每个文件该放进哪个文件夹——而且优先塞进你已有的文件夹,不硬造新目录。

简介

桌面用久了总会堆一堆文件:下载的 exe、截图、压缩包、随手放在外面的项目文件……想整理又懒得一个个分类。桌面整理大师就是把这份体力活交给 AI:它读取你桌面上的文件列表和已有的文件夹名,拼成一段提示词发给 DeepSeek,模型返回一份归类建议清单,你在弹窗里直接看结果。

工具的核心逻辑很简单也很克制 —— 只读取文件名、只输出建议,从不移动或删除你的任何文件。真正的整理动作还是由你自己来点鼠标。

特性

  • 优先复用已有文件夹:能塞进你已建好的目录就绝不再新建,避免整理完桌面多出一堆空文件夹。
  • 只读文件名,不读内容:程序只拿文件名和文件夹名去请求,不会上传文件本身。
  • Key 不落盘:API Key 由你当次输入,密码框显示,用完即弃,不写入任何文件。
  • 绿色单文件:一个 exe,免安装、免依赖管理,跑完自动在 exe 同目录写出 suggestion.txt。
  • 纯手工小工具:PowerShell + WinForms 写的 GUI,代码全在下面,欢迎自己改。

使用步骤

  1. 下载 desktop-organizer.exe,放到桌面或任意文件夹(建议单独放一个目录)。
  2. 双击运行;若被 Windows SmartScreen 拦截,点「更多信息」→「仍要运行」。
  3. 在弹出的窗口里输入你自己的 DeepSeek API Key(仅本次使用,不会保存)。
  4. 等待几秒,程序会弹窗展示归类建议,并在同目录生成 suggestion.txt。
  5. 照着建议手动整理文件 —— 工具不会动你的文件。

环境要求:Windows 10 / 11(需 .NET Framework 4.x,系统自带);DeepSeek API Key 需自行在 DeepSeek 开放平台申请。

下载与源码

v1.0 · 184,832 字节(约 181 KB)
SHA256 de637e92ba807f754871e15cde18ab73e06c33a6e85bab9f91ac5e8c99bc18b8

源码 · desktop-organizer.ps1(PowerShell,打包成 exe 前的原始脚本) UTF-8
$MODEL    = "deepseek-flash"
$BASE_URL = "https://api.deepseek.com"

$outDir = $PSScriptRoot
if (-not $outDir) { $outDir = $PWD.Path }
$outFile = Join-Path $outDir "suggestion.txt"

$desktop = [Environment]::GetFolderPath('Desktop')
Set-Location $desktop

$folders = Get-ChildItem -Directory | Select-Object -ExpandProperty Name
$files   = Get-ChildItem -File      | Select-Object -ExpandProperty Name

$selfNames = @("scan.exe", "scan.ps1", "suggestion.txt", "index.ico", "index.png")
$files = $files |
    Where-Object { $selfNames -notcontains $_ } |
    ForEach-Object { $_ -replace '\s*-\s*快捷方式(\.lnk)?$', '' -replace '\.lnk$', '' }

Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing

$form = New-Object System.Windows.Forms.Form
$form.Text = "桌面整理助手"
$form.Size = New-Object System.Drawing.Size(460, 180)
$form.StartPosition = "CenterScreen"
$form.FormBorderStyle = "FixedDialog"
$form.MaximizeBox = $false
$form.MinimizeBox = $false

$label = New-Object System.Windows.Forms.Label
$label.Text = "请输入你的 API Key(仅本次使用,不会保存到任何文件)"
$label.Location = New-Object System.Drawing.Point(20, 20)
$label.Size = New-Object System.Drawing.Size(410, 25)
$label.Font = New-Object System.Drawing.Font("Microsoft YaHei", 10)
$form.Controls.Add($label)

$textbox = New-Object System.Windows.Forms.TextBox
$textbox.Location = New-Object System.Drawing.Point(20, 55)
$textbox.Size = New-Object System.Drawing.Size(410, 28)
$textbox.UseSystemPasswordChar = $true
$textbox.Font = New-Object System.Drawing.Font("Consolas", 10)
$form.Controls.Add($textbox)

$ok = New-Object System.Windows.Forms.Button
$ok.Text = "确定"
$ok.Location = New-Object System.Drawing.Point(260, 100)
$ok.Size = New-Object System.Drawing.Size(80, 30)
$ok.DialogResult = [System.Windows.Forms.DialogResult]::OK
$ok.Font = New-Object System.Drawing.Font("Microsoft YaHei", 10)
$form.Controls.Add($ok)

$cancel = New-Object System.Windows.Forms.Button
$cancel.Text = "取消"
$cancel.Location = New-Object System.Drawing.Point(350, 100)
$cancel.Size = New-Object System.Drawing.Size(80, 30)
$cancel.DialogResult = [System.Windows.Forms.DialogResult]::Cancel
$cancel.Font = New-Object System.Drawing.Font("Microsoft YaHei", 10)
$form.Controls.Add($cancel)

$form.AcceptButton = $ok
$form.CancelButton = $cancel

$result = $form.ShowDialog()
if ($result -eq [System.Windows.Forms.DialogResult]::OK) {
    $apiKey = $textbox.Text
} else {
    exit 1
}
$form.Dispose()

if ([string]::IsNullOrWhiteSpace($apiKey)) {
    [System.Windows.Forms.MessageBox]::Show("API Key 为空,退出。", "错误", "OK", "Error")
    exit 1
}

$prompt = @"
你是一个 Windows 桌面整理助手。以下是用户桌面上的内容:

【已有的文件夹】(用户已经建好的,可以往里放文件)
$($folders -join "`n")

【散落的文件】(这些是需要整理的对象)
$($files -join "`n")

任务规则:
1. 针对【散落的文件】给出归类建议。
2. 【优先】把文件归入【已有的文件夹】里。如果某个文件能合理地放进某个已有文件夹,就放进去,不要另建新文件夹。
3. 只有当某个文件确实找不到合适的已有文件夹时,才建议新建文件夹。
4. 新建的文件夹名不要和已有的文件夹重名,也不要和已有文件夹语义重复。
5. 每个建议的文件夹名和文件名,都用中文引号 ""..."" 包裹。
6. 文件名不要带扩展名。
7. 建议的文件夹总数控制在 3-6 个(含已有文件夹和新文件夹)。

输出格式示例:

1. 放入已有文件夹:"工具"
   放入:"Visual Studio Code"、"Docker Desktop"

2. 建议新建文件夹:"浏览器与网络"
   放入:"Google Chrome"、"Microsoft Edge"、"WireGuard"

3. 放入已有文件夹:"大学"
   放入:"选课指南"

每个条目之间必须换行。
只输出建议列表,不要解释。
"@

$body = @{
    model    = $MODEL
    messages = @(
        @{ role = "user"; content = $prompt }
    )
    temperature = 0.3
} | ConvertTo-Json -Depth 10

$uri = "$BASE_URL/chat/completions"

$loading = New-Object System.Windows.Forms.Form
$loading.Text = "请稍候"
$loading.Size = New-Object System.Drawing.Size(320, 120)
$loading.StartPosition = "CenterScreen"
$loading.FormBorderStyle = "FixedDialog"
$loading.MaximizeBox = $false
$loading.MinimizeBox = $true
$loading.ControlBox = $true
$loading.ShowInTaskbar = $true

$loadingLabel = New-Object System.Windows.Forms.Label
$loadingLabel.Text = "正在请求 AI,请稍候..."
$loadingLabel.Location = New-Object System.Drawing.Point(20, 30)
$loadingLabel.Size = New-Object System.Drawing.Size(280, 30)
$loadingLabel.Font = New-Object System.Drawing.Font("Microsoft YaHei", 10)
$loadingLabel.TextAlign = "MiddleCenter"
$loading.Controls.Add($loadingLabel)

$loading.Add_FormClosing({
    param($sender, $e)
    if ($e.CloseReason -eq [System.Windows.Forms.CloseReason]::UserClosing) {
        $e.Cancel = $true
    }
})

$loading.Show()
$loading.Refresh()
$loading.Activate()
[System.Windows.Forms.Application]::DoEvents()

Add-Type -AssemblyName System.Net.Http

$client = New-Object System.Net.Http.HttpClient
$client.Timeout = [TimeSpan]::FromSeconds(120)
$client.DefaultRequestHeaders.Authorization =
    New-Object System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", $apiKey)

$content = New-Object System.Net.Http.StringContent(
    $body,
    [System.Text.Encoding]::UTF8,
    "application/json"
)

$task = $client.PostAsync($uri, $content)

while (-not $task.IsCompleted) {
    [System.Windows.Forms.Application]::DoEvents()
    Start-Sleep -Milliseconds 30
}

$loading.Close()
$loading.Dispose()

$response = $null
try {
    $response = $task.Result
} catch {
    [System.Windows.Forms.MessageBox]::Show("网络请求失败:`n$_", "错误", "OK", "Error")
    exit 1
}

$json = $response.Content.ReadAsStringAsync().Result

if (-not $response.IsSuccessStatusCode) {
    $errMsg = $json
    try {
        $errData = $json | ConvertFrom-Json
        if ($errData.error -and $errData.error.message) {
            $errMsg = $errData.error.message
        }
    } catch { }
    [System.Windows.Forms.MessageBox]::Show("API 返回错误 ($($response.StatusCode)):`n$errMsg", "错误", "OK", "Error")
    exit 1
}

try {
    $data = $json | ConvertFrom-Json
} catch {
    [System.Windows.Forms.MessageBox]::Show("解析响应失败:`n$json", "错误", "OK", "Error")
    exit 1
}

if ($data.error) {
    $errMsg = if ($data.error.message) { $data.error.message } else { $json }
    [System.Windows.Forms.MessageBox]::Show("API 错误:`n$errMsg", "错误", "OK", "Error")
    exit 1
}

if (-not $data.choices -or $data.choices.Count -eq 0) {
    [System.Windows.Forms.MessageBox]::Show("API 返回了空结果:`n$json", "错误", "OK", "Error")
    exit 1
}

$suggestion = $data.choices[0].message.content
$suggestion = $suggestion -replace "`r`n", "`n" -replace "`n", "`r`n"

$utf8NoBom = New-Object System.Text.UTF8Encoding($false)
[System.IO.File]::WriteAllText($outFile, $suggestion, $utf8NoBom)

$resultForm = New-Object System.Windows.Forms.Form
$resultForm.Text = "AI 建议"
$resultForm.Size = New-Object System.Drawing.Size(800, 600)
$resultForm.StartPosition = "CenterScreen"

$resultBox = New-Object System.Windows.Forms.TextBox
$resultBox.Multiline = $true
$resultBox.ScrollBars = "Both"
$resultBox.ReadOnly = $true
$resultBox.WordWrap = $true
$resultBox.Dock = "Fill"
$resultBox.Font = New-Object System.Drawing.Font("Microsoft YaHei", 10)
$resultBox.Text = $suggestion
$resultForm.Controls.Add($resultBox)

$resultForm.ShowDialog() | Out-Null
$resultForm.Dispose()

声明

本项目是个人技术学习与分享的产物:完全免费提供,不收费、无广告、无任何付费功能,不做任何盈利目的。

程序内置的提示词与代码均可自由查看、修改、二次学习;使用中调用 DeepSeek API 产生的费用由使用者自行承担。请勿将其用于任何商业转售用途。