Skip to content

Instantly share code, notes, and snippets.

@susemeee
Created July 29, 2020 11:11
Show Gist options
  • Save susemeee/3d0d09d975f5bd9b60fa924f25db5100 to your computer and use it in GitHub Desktop.
Save susemeee/3d0d09d975f5bd9b60fa924f25db5100 to your computer and use it in GitHub Desktop.
$src = ".\goog"
$dest = ".\goog2"
$num=1
Get-ChildItem $src -Recurse -Include *.gif, *.jpg, *.jpeg, *.png, *.bmp, *.heic, *.heif, *.mov, *.mp4, *.webp, *.avi, *.tif, *.flv, *.mts | ForEach-Object {
$nextName = Join-Path -Path $dest -ChildPath $_.name
while(Test-Path -Path $nextName)
{
$nextName = Join-Path $dest ($_.BaseName + "_$num" + $_.Extension)
$num+=1
}
$_ | Move-Item -Destination $nextName
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment