Skip to main content
PowerShell

PowerShell FOR loops and JOIN-PATH

By February 22, 2014No Comments

So long as we can find a practical use for them loops are fun and I always enjoy using them. I have  a project where I need to create folders in Windows based on a lesson number so a for loop in PowerShell will do this really quickly and simply. So let me share with you this simple trick.

for ($i=1;$i -le 8;$i++) {
$np="lesson_$i"
$p=Join-Path -Path "c:userandrewvideos" -ChildPath $np
mkdir $p
}