Reputation: 3
I want to create a folder in each subfolder with a number in it's name.
Lets say I have a following folder structure in my root folder:
\sub1\
\sub2\
\sub3\
after I've ran the command it should look like this:
\sub1\fold1
\sub2\fold2
\sub3\fold3
I'm new to all of this terminal stuff so i could only come up with how to create a folder in each subdirectory:
ls -directory | % {md ($_.name + '\FolderName')}
Thanks in advance.
Upvotes: 0
Views: 67
Reputation: 437933
Assuming you want sequence numbers starting with 1
, irrespective of the name of the parent directory:
$i=1
ls -directory | % { md (Join-Path $_.FullName "Folder$(($i++))") }
To instead incorporate the number embedded in the parent directory name:
ls -directory | % { md (Join-Path $_.FullName "Folder$($_.Name -replace '\D')") }
Upvotes: 1