Skip to content

Instantly share code, notes, and snippets.

@dgroft
Last active August 29, 2015 14:06
Show Gist options
  • Save dgroft/504b93f88834573bfb44 to your computer and use it in GitHub Desktop.
Save dgroft/504b93f88834573bfb44 to your computer and use it in GitHub Desktop.
Rename multiple files in a directory using Regex.
# rename multiple files in a directory using regex
# source: http://stackoverflow.com/questions/5574648/use-regex-powershell-to-rename-files
ls | %{ ren $_ $($_.name -replace '(TestFile_\w+)(\d+)(\.txt)', '${1}20140910${3}')}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment