Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Batch copy files to new directories that match the file name
- 1a.jpg
- 1b.jpg
- 1c.jpg
- 2a.jpg
- 2a.jpg
- 2c.jpg
- @echo off
- setlocal EnableDelayedExpansion
- for %%f in (*.jpg) do (
- set dir=%%~Nf
- set dir=!dir:~0,-1!
- if not exist !dir! md !dir!
- copy %%f !dir!
- )
- Get-ChildItem *.jpg | ForEach-Object {
- $destination = $_.FullName -replace '[a-f].jpg'
- if (-not (Test-Path -Path $destination -PathType Container)) {
- $null = New-Item -Path $destination -ItemType directory
- }
- Copy-Item -Path $_.FullName -Destination $destination
- }
- Get-ChildItem -Filter *.jpg | Group-Object {$_.Name[0]} | Foreach-Object { $_.Group | Copy-Item -Destination "C:test$($_.Name)" }
- Get-ChildItem *.jpg | Copy-Item -Destination { "C:test$($_.Name[0])" }
- dir -filter *.jpg | % { Copy-Item -PATH $_ -DESTINATION .$($_.BaseName.ToCharArray()[0]) }
Add Comment
Please, Sign In to add comment