Ranged letters

While I was playing around with the range operator I thought of this

001
002
003
004
005
$start = [byte][char]"a"
$finish = [byte][char]"h"

$start..$finish | 
foreach {New-Item -Path c:\test -Name "file$([char]$_).txt" -ItemType File}

 

Define your start and finish letters. Convert each to a char and then a byte.  This gives us the numeric value of the letter (ascii code).

We can then use those values in the range operator and create the files as we have already seen.

Leave a Reply