-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGTO2EDOC Pre-Processor.ps1
More file actions
executable file
·51 lines (38 loc) · 2.33 KB
/
GTO2EDOC Pre-Processor.ps1
File metadata and controls
executable file
·51 lines (38 loc) · 2.33 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
50
51
$InputLocation = "M:\test"
$OutputLocation = "M:\test\output"
#Get all GTO files from InputLocation
$files = get-childitem -filter *.gto -path $InputLocation
Foreach ($file in $files) {
$pattern = "\d\d\d[2-9]"
$found=$false
#Get full content for current file
$lines = Get-Content($file.FullName)|
Foreach-object{
#Get line content for AssignedToUserID zone
if($_ -match "AssignedToUserID-TZ"){
$a = $_
}
#Get line content for EFormID zone
if($_ -match "EFormID-TZ"){
$b = $_
}
#Check for page number line <> 0001
if($_ -match "DS_PGSEQ-DC:$pattern"){
if($found -eq $false){
$found=$true
}
}else{
$found=$false
}
#If a page number line is found (other than 0001) then write out page number line($_), AssignedTOUserID($a) and EFormID($b)
if($found -eq $true){
$_
$a
$b
}
if($found -ne $true){
#If not a page number line (or is a page number line = 0001) then just write out original line
$_
}
}| Set-Content($OutputLocation + "\" + $file.Name) #Output new file content to OutputLocation
}