Last active
January 28, 2020 10:10
-
-
Save berdosi/95466b54c9b299055395544b75e82146 to your computer and use it in GitHub Desktop.
Powershell snippet to do something with items with matching names in a directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get-ChildItem | | |
Where-Object -Property "Name" -Like "*remove this part from the filename*" | # filtering | |
ForEach-Object { | |
# action to do. Case in point: rename the file. Note the parentheeses around the two parameters. | |
Move-Item ($_.Name) ([System.Text.RegularExpressions.Regex]::Replace($_.Name, "remove this part from the filename", "")) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment