My code isn't working right, it's supposed to take a floating "this" or "that" and decide if it matches one of the mentioned words, however it is currently stopping at the first if
statement and saying all the words match it, which they definitely don't. I've tried -match
, -eq
, -like
.... I placed an "x" in front of the incorrect line. This is only a short line of a much larger code. (BRC - Bulk rename utility(commandline))
if ($this){
#exceptions
if ($that -like "Drücker" -or "Biegekern" -or "Führung" -or "Pressentisch"){Write-Host ("x($i/$rowMax) Replacing $that with $this")
.\BRC32 /DIR:$directory /INCLR /RECURSIVE /quiet /IGNOREFILEX /REPLACECI:"3_$that":"3_$this ($that)" /REPLACECI:_Dr.Pos.:"_$this ($that)_Pos_" /replaceci:" ":_ /execute
}
elseif ($that -like "Halteplatte" -or "Oberteil" -or "Unterteil" -or "Schieber"){Write-Host ("($i/$rowMax) Replacing $that with $this")
.\BRC32 /DIR:$directory /INCLR /RECURSIVE /quiet /IGNOREFILEX /REPLACECI:"3_$that":"3_$this ($that)" /replaceci:" ":_ /execute
.\BRC32 /DIR:$directory /INCLR /RECURSIVE /quiet /IGNOREFILEX /REPLACECI:"2_$that":"2_$this ($that)" /replaceci:" ":_ /execute
}
elseif ($that -like "Schnitt"){Write-Host ("($i/$rowMax) Replacing $that with $this")
.\BRC32 /DIR:$directory /INCLR /RECURSIVE /quiet /IGNOREFILEX /REPLACECI:"0_$that":"0_$this ($that)" /replaceci:" ":_ /execute
}
elseif ($that -like "Zusatzführung"){Write-Host ("($i/$rowMax) Replacing $that with $this")
.\BRC32 /DIR:$directory /INCLR /RECURSIVE /quiet /IGNOREFILEX /REPLACECI:"2_$that":"2_$this ($that)" /replaceci:" ":_ /execute
}
#main renaming function
elseif ($that){
Write-Host ("($i/$rowMax) Replacing $that with $this")
.\BRC32 /DIR:$directory /INCLR /RECURSIVE /quiet /IGNOREFILEX /REPLACECI:"_$that":"_$this ($that)" /replaceci:" ":_ /execute
}
}
elseif ($that){
Write-Host ("($i/$rowMax) Blank-Skip")
$blanks=$blanks+1
}
else {
$i=$rowMax
}