Ok I have a portion of a script that looks like this.
Switch(GCI $source\*.EDIPROD){
{(GC $_|Select -first 1).substring(176) -match "^834"}{$_ | ?{$_.Name -match "^.+?\.D(\d{6}).*"} | Rename-Item -NewName {"834Dailyin$($Matches[1]).txt"};Continue}
{(GC $_|Select -first 1).substring(405) -match "^030"}{$_ | ?{$_.Name -match "^.+?\.D(\d{6}).*"} | Rename-Item -NewName {"834Roster$($Matches[1]).txt"};Continue}
{(GC $_|Select -first 1).substring(176) -match "^820"}{$_ | ?{$_.Name -match "^.+?\.D(\d{6}).*"} | Rename-Item -NewName {"820Dailyin$($Matches[1]).txt"};Continue}
{(GC $_|Select -first 1) -match "NO INPUT"}{$_ | ?{$_.Name -match "^.+?\.D(\d{6}).*"} | Rename-Item -NewName {"NOINPUTin$($Matches[1]).txt"};Continue}
{(GC $_|Select -first 1) -match ""}{$_ | ?{$_.Name -match "^.+?\.D(\d{6}).*"} | Rename-Item -NewName Default {"Could not find 834 or 820 qualifier in file $_"};Continue}
}
My question comes into play on the first and second criteria.
So it's not looking for the same sub-string value, if a file comes in and has an 834 at substring 176, is it going to get matched before it checks for a ^030 at column 405?
I think it will evaluate the 176 column first, so maybe I should do two matches in the second one? or Move the second one to the first? What do you guys think?