Advertisement
Merzavets

Add leading zero to numeric filenames

Nov 26th, 2012
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Stupid method of adding leading zero to filenames like "1.mp3"
  2. ls | ren -NewName { $_.Name.PadLeft(7, "0") }
  3.  
  4. # OR (sorry, not complete desicion)
  5.  
  6. ls | foreach { $("{0:D5}" -f [int]$($_ -replace ".mp3")), "mp3" -join "." }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement