DEV Community

Meghan (she/her)
Meghan (she/her)

Posted on

Search/replace file names in Powershell

Posting a command I recently found that allows you find/replace file names in Powershell on Windows. <search> and <replace> both accept a regex or you can also add the -LiteralPath option to rename-item

get-childitem *.txt | foreach { rename-item $_ $_.Name.Replace("<search>", "<replace>") }
Enter fullscreen mode Exit fullscreen mode

In a world where Denvercoder69 actually does come back and reply to that blog post.

Top comments (1)

Collapse
 
nektro profile image
Meghan (she/her)
get-childitem * | foreach { rename-item -LiteralPath $_ $_.Name.Replace("", "") }