Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $AbrevMonthNames = (Get-Culture).DateTimeFormat.AbbreviatedMonthNames
- $InStuff = get-item *.csv
- # grab 3rd from last & then 2nd item of each .Split()
- $MonthAbr = $InStuff.name.Split('_')[-2].Split('-')[1]
- # correct for off-by-one
- $MonthNum = '{0:00}' -f ($AbrevMonthNames.IndexOf($MonthAbr) + 1)
- # replace the abbreviated month with the month number
- $outstuff = $instuff.name -replace $monthabr,$monthnum
- # rename the original file with the new name
- rename-item $instuff $outstuff
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement