Windows перемещение файлов в директории по совпадению части имени

В указанной директории ищем файлы с «_45» или «_16», перемещаем во внутреннюю создаваемую директорию.

$dir = "C:\work\pics"
$target = Join-Path $dir 'substrateInstagram'
New-Item -ItemType Directory -Path $target -Force | Out-Null
Get-ChildItem -Path $dir -Filter *.jpg -File |
  Where-Object { $_.BaseName -match '(_45|_16)' } |
  Move-Item -Destination $target
Поделиться
Отправить