Created
February 25, 2023 14:07
-
-
Save retorillo/ca38017172b9c3f958e164d0753d64df to your computer and use it in GitHub Desktop.
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
$d = "" | |
$lastfile = "" | |
dir | sort | foreach { | |
if (-not [math]::max($d, $_.name -match "([^\d]*)(\d+)(.+)")) { continue } | |
$nd = [int32]::parse($matches[2]) | |
if (($lastfile) -and ($d -ne "") -and (($d + 1) -ne $nd)) { | |
if (($nd - $d) -gt 3) { | |
echo "ERROR! MANUALLY CHECK AT " $lastfile.name | |
exit | |
} | |
($d+1)..($nd-1) | foreach { | |
$copyfile = ($matches[1] + $_ + $matches[3]) | |
copy $lastfile $copyfile | |
$count = $count + 1 | |
echo "FIXED:" $copyfile | |
} | |
} | |
$lastfile = $_ | |
$d = $nd | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment