Created
May 25, 2011 16:01
-
-
Save cromwellryan/991245 to your computer and use it in GitHub Desktop.
Prepend Zeros to files via PS
This file contains 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
function number-part($name) { return $name.Split(' ')[0] } | |
function prepend-if-needed($fi) { | |
$numberpart = number-part $fi.Name | |
$potentialnewname = "0" + $fi.Name | |
if( $numberpart.length -lt 2 ) { ren -Path $fi.FullName -NewName $potentialnewname } | |
} | |
ls | foreach { prepend-if-needed $_ } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment