Um script do PowerShell:
Get-ChildItem *-*.pdf|Foreach-object {
$Dir, $File = $_.Name.Split('-')[0,1]
if (!(Test-Path $Dir)){MD $Dir}
$_| Move -Destination ("$Dir\$File")
}
O lote:
@echo off
for /F "Tokens=1* delims=-" %%A in ('Dir /B "*-*.pdf"') do (
If not exist ".\%%A" MD ".\%%A"
Move "%%A-%%B" "%%A\%%B"
)
Árvore antes:
> tree /f .
Z:\
10389-2001.pdf
10815-2017.pdf
Árvore depois:
> tree /f .
Z:\
├───10389
│ 2001.pdf
│
└───10815
2017.pdf