feat(archive): 新增 media-archive,一键把整理好的目录归档进媒体库
- scripts/media_archive.py:按目录名里的 [tmdbid-N] 查 TMDB,结合 original_language / origin_country / genres 给出分类建议;交互选择或 --to 指定; 同盘 os.rename(跨盘回退 shutil.move),目标存在则拒绝,移动后校验文件数/体积; 可选触发 Jellyfin /Library/Refresh - scripts/media-archive.ps1 + remote-common.ps1:Windows 侧包装,路径翻译与 media-rename 共用 - 右键菜单新增「SceneRename 归档」,共 10 个注册项 - deploy.ps1 同时安装 /usr/local/bin/media-archive
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
#Requires -Version 7.0
|
||||
<#
|
||||
.SYNOPSIS
|
||||
在 Windows 资源管理器右键菜单里注册「SceneRename 重命名」。
|
||||
在 Windows 资源管理器右键菜单里注册 SceneRename 的「重命名」「归档」两项。
|
||||
|
||||
.DESCRIPTION
|
||||
只写 HKCU(当前用户),不需要管理员权限,可随时用 uninstall-explorer-menu.ps1 移除。
|
||||
注册位置:
|
||||
HKCU\Software\Classes\Directory\shell\SceneRename (文件夹右键)
|
||||
HKCU\Software\Classes\Directory\Background\shell\SceneRename (文件夹空白处右键)
|
||||
HKCU\Software\Classes\SystemFileAssociations\.mkv\shell\SceneRename
|
||||
注册位置(每处两个菜单项):
|
||||
HKCU\Software\Classes\Directory\shell\<Key> (文件夹右键)
|
||||
HKCU\Software\Classes\Directory\Background\shell\<Key> (文件夹空白处右键)
|
||||
HKCU\Software\Classes\SystemFileAssociations\.mkv\shell\<Key>
|
||||
... 同上 .mp4 / .avi(文件右键,取其所在目录)
|
||||
|
||||
.EXAMPLE
|
||||
@@ -31,34 +31,41 @@ else {
|
||||
$pwsh = (Get-Command pwsh -ErrorAction Stop).Source
|
||||
}
|
||||
|
||||
function New-MenuCommand([string]$Token) {
|
||||
# Token: %1 = 选中的文件夹/文件;%V = 当前目录
|
||||
return '"' + $pwsh + '" -NoLogo -NoProfile -File "' + $runner + '" -Pause "' + $Token + '"'
|
||||
}
|
||||
|
||||
$menuText = 'SceneRename 重命名'
|
||||
|
||||
$repoRoot = Split-Path -Parent $PSScriptRoot
|
||||
$iconPath = Join-Path $repoRoot 'assets\scenerename.ico'
|
||||
if (-not (Test-Path -LiteralPath $iconPath)) { $iconPath = $pwsh }
|
||||
|
||||
$targets = @(
|
||||
@{ Key = 'HKCU:\Software\Classes\Directory\shell\SceneRename'; Token = '%1' },
|
||||
@{ Key = 'HKCU:\Software\Classes\Directory\Background\shell\SceneRename'; Token = '%V' },
|
||||
@{ Key = 'HKCU:\Software\Classes\SystemFileAssociations\.mkv\shell\SceneRename'; Token = '%1' },
|
||||
@{ Key = 'HKCU:\Software\Classes\SystemFileAssociations\.mp4\shell\SceneRename'; Token = '%1' },
|
||||
@{ Key = 'HKCU:\Software\Classes\SystemFileAssociations\.avi\shell\SceneRename'; Token = '%1' }
|
||||
$actions = @(
|
||||
@{ Key = 'SceneRename'; Text = 'SceneRename 重命名'; Action = 'rename' },
|
||||
@{ Key = 'SceneRenameArchive'; Text = 'SceneRename 归档'; Action = 'archive' }
|
||||
)
|
||||
|
||||
foreach ($item in $targets) {
|
||||
$commandKey = Join-Path $item.Key 'command'
|
||||
New-Item -Path $item.Key -Force | Out-Null
|
||||
New-Item -Path $commandKey -Force | Out-Null
|
||||
New-ItemProperty -Path $item.Key -Name '(default)' -Value $menuText -PropertyType String -Force | Out-Null
|
||||
New-ItemProperty -Path $item.Key -Name 'Icon' -Value $iconPath -PropertyType String -Force | Out-Null
|
||||
New-ItemProperty -Path $commandKey -Name '(default)' -Value (New-MenuCommand $item.Token) -PropertyType String -Force | Out-Null
|
||||
$locations = @(
|
||||
@{ Shell = 'HKCU:\Software\Classes\Directory\shell'; Token = '%1' },
|
||||
@{ Shell = 'HKCU:\Software\Classes\Directory\Background\shell'; Token = '%V' },
|
||||
@{ Shell = 'HKCU:\Software\Classes\SystemFileAssociations\.mkv\shell'; Token = '%1' },
|
||||
@{ Shell = 'HKCU:\Software\Classes\SystemFileAssociations\.mp4\shell'; Token = '%1' },
|
||||
@{ Shell = 'HKCU:\Software\Classes\SystemFileAssociations\.avi\shell'; Token = '%1' }
|
||||
)
|
||||
|
||||
function New-MenuCommand([string]$Action, [string]$Token) {
|
||||
'"' + $pwsh + '" -NoLogo -NoProfile -File "' + $runner + '" -Action ' + $Action + ' -Pause "' + $Token + '"'
|
||||
}
|
||||
|
||||
foreach ($loc in $locations) {
|
||||
foreach ($item in $actions) {
|
||||
$key = Join-Path $loc.Shell $item.Key
|
||||
$commandKey = Join-Path $key 'command'
|
||||
New-Item -Path $key -Force | Out-Null
|
||||
New-Item -Path $commandKey -Force | Out-Null
|
||||
New-ItemProperty -Path $key -Name '(default)' -Value $item.Text -PropertyType String -Force | Out-Null
|
||||
New-ItemProperty -Path $key -Name 'Icon' -Value $iconPath -PropertyType String -Force | Out-Null
|
||||
New-ItemProperty -Path $commandKey -Name '(default)' -Value (New-MenuCommand $item.Action $loc.Token) -PropertyType String -Force | Out-Null
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host '✔ 已注册右键菜单(当前用户)' -ForegroundColor Green
|
||||
$targets | ForEach-Object { Write-Host (' - ' + $_.Key) -ForegroundColor DarkGray }
|
||||
foreach ($item in $actions) {
|
||||
Write-Host (" - 「{0}」 × 文件夹 / 空白处 / mkv,mp4,avi" -f $item.Text) -ForegroundColor DarkGray
|
||||
}
|
||||
Write-Host '提示:若菜单未立即出现,重启一次 explorer.exe 或重新登录。' -ForegroundColor Yellow
|
||||
|
||||
Reference in New Issue
Block a user