Skip to content

Instantly share code, notes, and snippets.

@retorillo
Created February 25, 2023 14:07
Show Gist options
  • Save retorillo/ca38017172b9c3f958e164d0753d64df to your computer and use it in GitHub Desktop.
Save retorillo/ca38017172b9c3f958e164d0753d64df to your computer and use it in GitHub Desktop.
$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