Skip to content

Instantly share code, notes, and snippets.

@susemeee
Created July 29, 2020 11:11
Show Gist options
  • Select an option

  • Save susemeee/3d0d09d975f5bd9b60fa924f25db5100 to your computer and use it in GitHub Desktop.

Select an option

Save susemeee/3d0d09d975f5bd9b60fa924f25db5100 to your computer and use it in GitHub Desktop.

Revisions

  1. susemeee created this gist Jul 29, 2020.
    16 changes: 16 additions & 0 deletions flatten.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    $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
    }