5

I would like to create this folder structure using PowerShell:

D:\feb\win10\x64\Folder1
                 folder2

1 Answer 1

5

You are looking for the New-Item cmdlet.

Here an example to create a single folder using the New-Item cmdlet:

New-item "D:\feb#16\LV2\7212\win10\x64\audio" -ItemType Directory -force

Certainly you could do this for each the subfolders you want to create. You could also create a list of your subfolders using @('folder1' ,'folder2', ...) and iterate over these subfolders to create them. The following example uses the Join-Path cmdlet to combine the base path with the current sub folder which is $_ (the current pipeline object) and creates the directory using the above mentioned New-Item cmdlet:

@('audio', 'chipset', 'communication', 'docks', 'input', 'network', 'security', 'storage', 'video') |
    ForEach-Object {
        New-Item (Join-Path 'D:\feb#16\LV2\7212\win10\x64\' $_) -ItemType Directory -force
    }

Sign up to request clarification or add additional context in comments.

6 Comments

I feel that this might be over-complicated for a newbie. I would recommend you include a most basic example to create a single folder and explain your code in a bit more detail!
as a newbie its helped me your descriptions also to understand. am expecting more helps from you guys. :)
hi @MartinBrandl can you help me the same scenario with parsing a Excel sheet for giving folder names. like Audio,chip set.....
probably yes, but please start a new question
@MartinBrandl ok i will start a new question
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.