Skip to content

Instantly share code, notes, and snippets.

@ghotz
Created July 14, 2015 11:21
Show Gist options
  • Save ghotz/410dc5340f50b62afa9a to your computer and use it in GitHub Desktop.
Save ghotz/410dc5340f50b62afa9a to your computer and use it in GitHub Desktop.
Rename and moves perfmon logs formatted with a certain pattern
# Normalizes perfmon logs names given a set of directories
# following the pattern COMPUTERNAME_YYYYMMDD-NNNNNN
# by moving log files to the root dir and assigning a unique name
$PALDir = "D:\Temp\PAL"
Get-ChildItem $PALDir -Directory |
? { $_.Name -match "(?<ComputerName>\w*)_(?<ISODate>\d{4}\d{2}\d{2})-(?<Sequence>\d{6})" } |
% {
$file = Get-ChildItem $_.FullName;
$file.MoveTo($PALDir + "\" + $Matches["ComputerName"] + "_PAL_" + $Matches["ISODate"] + "_" + $Matches["Sequence"]+".blg");
rd $_.FullName;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment