Forum Discussion
John_Dodo
Jul 13, 2022Brass Contributor
Rename file using Regex
Hello, I need to bulk rename files usgin regex. I'm very bad with regex 😕 Here is a simplified sample: ...
$source = "blabla"
$target = "blibli"
$files = Get-ChildItem -file -path ".\D...
LainRobertson
Jul 13, 2022Silver Contributor
Here's an ultra-simple example.
Strictly speaking, if you are replacing a contiguous text block, using a string's .Replace() method would be faster but let's not get distracted with that, since working with the file system means you won't realise any performance benefit from going down that path.
Cheers,
Lain
John_Dodo
Jul 13, 2022Brass Contributor
Great thank you Lain, then if my understanding is right I don't even need to check if the file name actually contains the $source string, the replace method will simply do nothing if it doesn't find it, am I right?
- LainRobertsonJul 13, 2022Silver Contributor