Last active
August 9, 2020 16:08
-
-
Save marcduiker/2199c57cc616c418a510a9bd6c25977d to your computer and use it in GitHub Desktop.
Incrementally rename files for ffmpeg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$prefix="frame_" | |
$files = Get-ChildItem "<Path where the pngs are>" -Filter *.png | Sort-Object | |
$fileCount = 0 | |
$files | | |
Foreach-Object { | |
$fileCount++ | |
$currentFileNumber = [int]$_.BaseName.Substring($prefix.Length) | |
if ($currentFileNumber -ne $fileCount) { | |
$newFileFormat = "$prefix{0:d4}.png" -f $fileCount | |
Rename-Item $_.FullName $newFileFormat | |
Write-Output "$newFileFormat (renamed)" | |
} | |
else { | |
$orig = $_.Name + " (orig)" | |
Write-Output $orig | |
} | |
} | |
Write-Output "Done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment