Created
February 2, 2016 21:50
-
-
Save mikecasas/bbf67e6095f74ad80e0f to your computer and use it in GitHub Desktop.
Renames the files in a given folder
This file contains hidden or 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
cls | |
$mainFolder=("C:\Users\mike-admin\Audio\pbc-2015") | |
$finalFolder=($mainFolder + "\wednesday\") | |
$lines=Get-ChildItem $finalFolder | select name | |
foreach ($line in $lines) { | |
$fn=$line.Name; | |
$firstDash = $fn.IndexOf("-") | |
$baseFileName = ('-' + $fn.Substring($firstDash+1)).ToLower() | |
$i=($finalFolder + $fn); | |
$yr = $fn.Substring(0,2) | |
$mo = $fn.Substring(2,2) | |
$da = $fn.Substring(4,2) | |
$a = $yr.Replace("15", "2015") | |
$newFn=($a + '-' + $mo + '-' + $da + $baseFileName) | |
rename-item -path $i -newname $newFn | |
#Write-Output $newFn | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment