i want to replace a square bracket in powershell, to change the title.
my code:
if($finaltitlewithouterrors -like "*`[*`]") {
$finaltitlewithouterrors=$finaltitlewithouterrors.Replace("[", '')
}
i tried other schemas but none of them work, like
if($finaltitlewithouterrors -like "*`[*") {
$finaltitlewithouterrors=$finaltitlewithouterrors.Replace("`[", '')
}
i also tried it with
*``[*
i found a similar question (https://stackoverflow.com/questions/54094312/how-do-i-use-square-brackets-in-a-wildcard-pattern-in-powershell-get-childitem#:~:text=Square%20brackets%20can%20be%20used%20as%20a%20wildcard,and%20consequently%20the%20support%20in%20Powershell%20is%20spotty.) but noting of it work.
for example i have a name called:
BatmanTheDarkNight[1].pdf
and the final name should look like:
BatmanTheDarkNight.pdf
or
BatmanTheDarkNight1.pdf