Skip to content

Instantly share code, notes, and snippets.

@Timberfang
Last active May 15, 2023 16:05
Show Gist options
  • Save Timberfang/84d3dfc962e33156f57bcd5774bda4d3 to your computer and use it in GitHub Desktop.
Save Timberfang/84d3dfc962e33156f57bcd5774bda4d3 to your computer and use it in GitHub Desktop.
Find missing numbers in a list of file names.
Set-StrictMode -Version 3.0
#Requires -Version 7.0
# Find missing numbers in a list of file names containing four digit numbers in parentheses.
# Outputs list of missing numbers to pipeline.
[System.Int32[]]$Iteration = Get-ChildItem $Path | Where-Object{$_.Name -match "\(\d{4}\)"} | ForEach-Object{$Matches[0]}
$Iteration[0]..$Iteration[-1] | Where-Object{$_ -notin $Iteration}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment