Adonis0123/adonis-skills / skills/file-tidy
file-tidy
VerifiedOrganize a person's own files on macOS, Linux or Windows into one numbered Root (default ~/Files): empty Downloads and screenshot Inboxes, clear the desktop, file personal, work, finance, media, installer and sensitive files into Categories, find duplicate files, and point app save locations at the Inboxes. Use when the user asks, in any language (e.g. 整理文件/桌面/下载、去重), to tidy, sort, dedupe or file their Desktop, Downloads, home folder, documents or data drives, set default download or screenshot folders, repeat the scheme on a new computer, or undo a previous tidy. Every run is planned, verified, reversible and never deletes. Not for code repositories, cloud documents, photo-library management or disk-space analysis alone.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 11.9 KB |
| assets/default-config.json | config | 2.0 KB |
| evals/evals.json | config | 8.5 KB |
| references/app-defaults.md | markdown | 6.4 KB |
| references/glossary.md | markdown | 3.3 KB |
| references/windows.md | markdown | 26.2 KB |
| scripts/file_tidy.py | script | 45.5 KB |
| scripts/test_file_tidy.py | script | 70.5 KB |
| scripts/windows/probe-locations.ps1 | script | 4.4 KB |
| scripts/windows/shortcuts.ps1 | script | 4.7 KB |
scripts/windows/shortcuts.ps1
View on GitHub<#
.SYNOPSIS
Find Desktop and Start menu shortcuts that point into a folder, and optionally retarget them.
.EXAMPLE
shortcuts.ps1 -From 'D:\games' # list only
shortcuts.ps1 -From 'D:\games' -To 'G:\games\standalone' -Apply
shortcuts.ps1 -From 'D:\games' -Roots 'C:\temp\links' # search other folders instead
shortcuts.ps1 -FromBase64 <utf8-base64> -ToBase64 <utf8-base64> -Apply # non-ASCII paths from WSL
.DESCRIPTION
Matching is case-insensitive on the path prefix. Without -Apply nothing changes.
With -Apply only shortcuts whose new target exists are rewritten; the rest are listed as missing.
-FromBase64/-ToBase64 take the path as UTF-8 base64 so non-ASCII paths survive any caller codepage,
e.g. from WSL: -FromBase64 "$(printf '%s' 'G:\games\QQ...' | base64 -w0)".
Paths are compared after Unicode NFC normalization; rewritten fields keep their original form
after the prefix. A shortcut whose original prefix does not normalize to the same length is
left alone and listed with status nfc-mismatch.
#>
param(
[string] $From,
[string] $To,
[string] $FromBase64,
[string] $ToBase64,
[switch] $Apply,
[string[]] $Roots
)
$ErrorActionPreference = 'Stop'
[Console]::OutputEncoding = [Text.Encoding]::UTF8
function ConvertFrom-Utf8Base64([string] $Value) { [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($Value)) }
function Get-Nfc([string] $Value) { if ($Value) { $Value.Normalize([Text.NormalizationForm]::FormC) } else { $Value } }
if ($FromBase64) { $From = ConvertFrom-Utf8Base64 $FromBase64 }
if ($ToBase64) { $To = ConvertFrom-Utf8Base64 $ToBase64 }
if (-not $From) { throw 'Pass -From or -FromBase64.' }
if ($From.Contains('?') -or ($To -and $To.Contains('?'))) { throw "Path contains '?', a sign the caller's codepage dropped characters; pass -FromBase64/-ToBase64 instead." }
if ($Roots | Where-Object { $_ -and $_.Contains('?') }) { throw "-Roots contains '?', a sign the caller's codepage dropped characters; pass ASCII paths or run from PowerShell." }
$From = Get-Nfc $From
$To = Get-Nfc $To
$fromPrefix = $From.TrimEnd('\') + '\'
$fromBase = $From.TrimEnd('\')
# The part of $Value after the -From prefix, taken from the original string; $null when the
# original prefix is not the same length as its NFC form (then a cut would land mid-character).
function Get-Tail([string] $Value) {
$n = $fromBase.Length
if (-not $Value -or $Value.Length -lt $n) { return $null }
if (-not [string]::Equals((Get-Nfc $Value.Substring(0, $n)), $fromBase, [StringComparison]::OrdinalIgnoreCase)) { return $null }
$tail = $Value.Substring($n)
if ($tail -and -not $tail.StartsWith('\')) { return $null }
return $tail
}
if ($Roots) { $searchRoots = @($Roots | Where-Object { Test-Path -LiteralPath $_ }) } else { $searchRoots = @(
[Environment]::GetFolderPath('Desktop'),
[Environment]::GetFolderPath('CommonDesktopDirectory'),
[Environment]::GetFolderPath('StartMenu'),
[Environment]::GetFolderPath('CommonStartMenu')
) | Where-Object { $_ -and (Test-Path $_) } }
$wsh = New-Object -ComObject WScript.Shell
$result = @()
foreach ($root in $searchRoots) {
Get-ChildItem -LiteralPath $root -Recurse -Filter *.lnk -ErrorAction SilentlyContinue | ForEach-Object {
$lnk = $wsh.CreateShortcut($_.FullName)
$fields = @('TargetPath', 'WorkingDirectory', 'IconLocation')
$hit = $fields | Where-Object { ((Get-Nfc $lnk.$_) + '\').StartsWith($fromPrefix, [StringComparison]::OrdinalIgnoreCase) }
if (-not $hit) { return }
$row = [ordered]@{ shortcut = $_.FullName; target = $lnk.TargetPath; status = 'listed' }
$toBase = if ($To) { $To.TrimEnd('\') } else { $null }
$targetHit = ((Get-Nfc $lnk.TargetPath) + '\').StartsWith($fromPrefix, [StringComparison]::OrdinalIgnoreCase)
if ($toBase -and -not $targetHit) { $row.status = 'target-outside-from' } # only working dir or icon match; left alone
elseif ($toBase) {
$updates = [ordered]@{}
$mismatch = $false
foreach ($field in $hit) {
$tail = Get-Tail $lnk.$field
if ($null -eq $tail) { $mismatch = $true } else { $updates[$field] = $toBase + $tail }
}
if ($mismatch) { $row.status = 'nfc-mismatch' }
else {
$newTarget = $updates['TargetPath']
$row.new_target = $newTarget
if (-not (Test-Path -LiteralPath $newTarget)) { $row.status = 'missing-new-target' }
elseif ($Apply) {
foreach ($field in $updates.Keys) { $lnk.$field = $updates[$field] }
$lnk.Save()
$row.status = 'retargeted'
}
}
}
$result += [pscustomobject]$row
}
}
ConvertTo-Json -InputObject @($result) -Depth 3
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementation | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirements | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallback | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |