-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNGFIleReplace.ps1
More file actions
executable file
·49 lines (37 loc) · 1.65 KB
/
NGFIleReplace.ps1
File metadata and controls
executable file
·49 lines (37 loc) · 1.65 KB
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
42
43
44
45
46
47
48
49
cls
$outputFile = "C:\test for Peter\test\output.txt"
$images = gci "C:\Test for Peter\Images\"
$BDFs = gci -path "C:\Test for Peter\Test"
$imagePathPattern = "^\\\\lynx2\\Customers\\NationalGuard-TrainingOrders\\AnyDOC_Output\\Images\\(\d*).tif.*$"
$imageArray = @()
$imageArrayName=@()
foreach($file in $BDFS){
foreach($image in $images){
$bdfName = [int]$image.BaseName
$imageArray += $bdfName
$imageArrayName += $image.FullName
}
$lines = Get-Content -path $file.FullName|
foreach-object{
$processed = $false
if($_ -match $imagePathPattern){
for($i = 0; $i -lt $imageArray.length; $i++){
if([int]$Matches[1] - 1 -eq $imageArray[$i] -and $oldMatch -ne [int]$Matches[1] -1){
$imagePathName = $imageArrayName[$i]
[string]$imagePathName += "|"
Add-Content -value $imagePathName -path $outputFile
Add-Content -value $_ -path $outputFile
$processed = $true
}
}
if($processed -eq $false){
Add-Content -value $_ -path $outputFile
$processed = $true
}
$oldMatch = $Matches[1]
}
}
$holdFileName = $file.Name
Remove-Item -Path $file.FullName
Rename-Item -path $outputFile -NewName $holdFileName
}