regex
1 TopicRename 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 ".\Desktop\test" -Recurse .. foreach ($file in $files) { if($($file.Name).ToLower().contains($source)){ echo "$($file.Name) contains $source)"} else{ echo "$($file.Name) does NOT contain $source)" } Now I want to replace the echo lines with something similar to : $NewName = $_.Name -replace "regex syntax..." #I want to manage the fact that my file could be named blabla.txt but also 4141343blablaffjs.txt Rename-Item -Path $_.FullName -NewName $NewName This is where I need your help. Thank you.2.8KViews0likes3Comments