本帖最后由 flashercs 于 2019-12-2 20:21 编辑
- @echo off
- cd /d "%~dp0"
- powershell -noprofile -command "Split-Path -Path (Convert-Path -Path '*#[0-9]*.pdf') -Leaf | Where-Object {(Test-Path -LiteralPath $_ -PathType Leaf)}|Select-Object -Property @{Name='Id';Expression={if($_ -match '(?<=#)\d+'){$Matches[0] -as [int]}}},@{Name='FileName';Expression={$_}}|Sort-Object -Property 'Id'|Group-Object -Property 'Id'|ForEach-Object -Begin {$num=0} -Process {$dirname='返修'+(++$num);New-Item -Path $dirname -ItemType Directory -Verbose -ErrorAction SilentlyContinue;Move-Item -LiteralPath ($_.Group|Foreach-Object{$_.FileName}) -Destination $dirname -Verbose}"
- pause
- exit /b
复制代码
|