-
Notifications
You must be signed in to change notification settings - Fork 0
/
chk-seq.ps1
41 lines (38 loc) · 1.11 KB
/
chk-seq.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# this script checks a given folder for conseductive file namings as there are used for image sequences
# it returns missing numbers
if ($args.Length -eq 0)
{
echo "path missing"
echo "Usage: chk-seq <path>"
break
}
else
{
# initialize the items variable with the
# contents of a directory
$items = Get-ChildItem -Path $args[0]
#create int array to store filenumbers
$ArrList = [System.Collections.ArrayList]@()
#create arraylist to store missing filenames
$files = [System.Collections.ArrayList]@()
# enumerate the items array
# find all elements containing at least 3 digits in their name, converting them into int and adding into a new arraylist
foreach ($item in $items)
{
# if the item is NOT a directory, then process it.
if ($item.Attributes -ne "Directory" -and $item.BaseName -match '(\d{3})')
{
[Void]$ArrList.Add($item.BaseName)
}
}
# sort
[Void]($ArrList | Sort-Object)
#parsing arraylist checking for conseductive numbers
for ($i=1; $i -le $ArrList.Count;$i++)
{
if ($ArrList[$i]-$ArrList[$i-1] -gt 1)
{
Write-Host ($ArrList[$i]-1) is missing
}
}
}