Search/replace file names in Powershell
Meghan (she/her)

Meghan (she/her) @nektro

About: 24. Local trans witch who prefers to do magic with a keyboard. she/her. Currently hacking away at making the Web less centralized.

Location:
Massachusetts, USA
Joined:
Mar 13, 2017

Search/replace file names in Powershell

Publish Date: Jul 10 '18
24 1

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.

Comments 1 total

  • Meghan (she/her)
    Meghan (she/her)Aug 11, 2018
    get-childitem * | foreach { rename-item -LiteralPath $_ $_.Name.Replace("", "") }
    
Add comment