Skip to content

Instantly share code, notes, and snippets.

@sannae
Created October 24, 2022 08:18
Show Gist options
  • Save sannae/c122f99b4dd3cf4d023324496c7fc0d6 to your computer and use it in GitHub Desktop.
Save sannae/c122f99b4dd3cf4d023324496c7fc0d6 to your computer and use it in GitHub Desktop.
The script renames all the files (found recursively from a root path) whose filename matches the pattern specified
# Root folder
$Path = "\YOUR-PATH-HERE"
# Regex pattern (in this example, something like "(2022_10_10 08_30 UTC)"
$pattern = ".[0-9]+_[0-9]+_[0-9]+ [0-9]+_[0-9]+ UTC."
foreach ($file in $(get-childitem $Path -Recurse) ) {
if ($file.Name -match $pattern){
Rename-iTem $File.FullName $($($file.FullName).Replace($Matches[0],""))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment