# Making Folders and Files: New-Item

New-Item makes new folders and files where you say, several at once or a whole path of folders in one go, -Value puts text into a new file, and -Force means "it's fine if it's already there" for a folder but "replace it" for a file.

Novice · PowerShell · Operating System · Updated November 10, 2026

## After this lesson you can

- Make a folder, several folders, or folders inside new folders with New-Item -ItemType Directory
- Make a file, empty or with a line of text, with New-Item -ItemType File and -Value, and say what -Force does to a folder or file that's already there

## Key takeaways

- `New-Item -ItemType Directory` makes a folder, and `New-Item -ItemType File` makes a file. PowerShell answers with a row for each new item.
- Give several paths with commas between them, and New-Item makes them all. A folder path makes every missing folder on the way.
- `-Value` puts a line of text into a new file.
- For a folder that's already there, `-Force` leaves it as it is. For a file, `-Force` replaces it with a new one, so check with `-WhatIf` first.

A new school term starts on Monday. You want a folder for the term, a folder inside it for each class, a homework folder for math, and a file for your class schedule. In File Explorer that's right-click, **New**, **Folder**, type a name, press Enter, double-click into it, and again, eight or nine times. In PowerShell it's three lines, and next term the same lines take seconds. People who set up folders as part of their job work this way too: an IT tech preparing a new employee's laptop, or a web developer starting a project with the same five folders every time.

## A new folder: New-Item -ItemType Directory

`New-Item` (read "new item") makes something new. An *item* is anything a folder can hold: a file, or another folder. `-ItemType` says which kind, and `Directory` is PowerShell's word for a folder. Go to your practice folder and make a folder for the term:

```powershell
Set-Location ~\terminal-practice
New-Item -ItemType Directory fall-term
```

```text
    Directory: C:\Users\Sam\terminal-practice

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d----           8/31/2026  7:15 PM                fall-term
```

PowerShell answers with a row in the same columns `Get-ChildItem` uses: a `d` in Mode for a folder, then its name. Your date and time will be the moment you made it.

The short name is `mkdir`, from *make directory*: `mkdir fall-term` does the same. On a Mac or Linux, `mkdir` runs the system's own program instead, which makes the folder the same way but prints nothing.

## Several at once, and folders inside new folders

Give New-Item several paths with commas between them, and it makes them all:

```powershell
New-Item -ItemType Directory fall-term\biology, fall-term\history, fall-term\math\homework
```

```text
    Directory: C:\Users\Sam\terminal-practice\fall-term

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d----           8/31/2026  7:15 PM                biology
d----           8/31/2026  7:15 PM                history

    Directory: C:\Users\Sam\terminal-practice\fall-term\math

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d----           8/31/2026  7:15 PM                homework
```

There was no `math` folder, and you didn't make one, but `homework` is inside `math` now. When a folder path runs through folders that aren't there yet, New-Item makes each one on the way, so a whole path takes one command.

## A new file: -ItemType File and -Value

A file's name usually ends with a **file extension**, the letters after the last dot: `.txt` for plain text, `.jpg` for a photo, `.docx` for a Word document. Windows reads it to decide which app opens the file. `-ItemType File` makes a file, empty and ready to type into:

```powershell
New-Item -ItemType File fall-term\math\homework\week-1.txt
```

```text
    Directory: C:\Users\Sam\terminal-practice\fall-term\math\homework

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a---           8/31/2026  7:15 PM              0 week-1.txt
```

A Length of `0` means it's empty. `-Value` puts a line of text in as the file is made:

```powershell
New-Item -ItemType File fall-term\schedule.txt -Value 'Biology: Monday and Wednesday, 9 AM'
Get-Content fall-term\schedule.txt
```

```text
    Directory: C:\Users\Sam\terminal-practice\fall-term

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a---           8/31/2026  7:15 PM             35 schedule.txt

Biology: Monday and Wednesday, 9 AM
```

Unlike a folder, a file needs its folder to be there already. `New-Item -ItemType File fall-term\english\reading-list.txt` stops with `Could not find a part of the path`, because there's no `english` folder yet. Make the folder first.

## Already there? -Force, and -WhatIf first

Run the first command a second time, and New-Item refuses rather than touch what's there:

```powershell
New-Item -ItemType Directory fall-term
```

```text
New-Item: An item with the specified name C:\Users\Sam\terminal-practice\fall-term already exists.
```

Adding `-Force` (read "force") changes that. For a folder, it means "it's fine if it's there": New-Item answers with the folder you already have and leaves it, and everything in it, as it is. That's why the practice-folder lines in earlier lessons use `-Force`: they're safe to run twice.

For a file, `-Force` means something stronger: *replace it*. `New-Item -ItemType File fall-term\schedule.txt -Force` swaps your schedule for a new, empty file, with no question asked. Before any command that might replace something, add `-WhatIf` (read "what if"). PowerShell says what it would do, and does nothing:

```powershell
New-Item -ItemType File fall-term\schedule.txt -Force -WhatIf
```

```text
What if: Performing the operation "Create File" on target "Destination: C:\Users\Sam\terminal-practice\fall-term\schedule.txt".
```

"Create File" on a file you already have means a new, empty one in its place. Most commands that change things take `-WhatIf`, and the rest of this chapter uses it often.

Windows PowerShell 5.1 runs everything in this lesson the same way, with six letters in Mode (`d-----`). On a Mac or Linux, write the paths with `/`.

**Try it.** Make the folders for something of your own (next term's classes, a hobby, a trip) with one New-Item, then look at them with `Get-ChildItem`.

## Try it in the terminal

[Terminal Quest: Moving Day, goal 2](https://www.ask-codey.com/games/terminal-quest/new-place/powershell/step): played right on the lesson page.

You've moved into a new apartment, and the movers left everything in the hallway. Make a bookshelf, a new folder, in the living room.

## Check yourself

2 questions to try on the lesson page.

## So what

Every project, term or trip starts with a few folders. With New-Item, a whole set of them is one line you can keep and run again next time.

## Key terms

- [New-Item](https://www.ask-codey.com/glossary/new-item)
- [File Extension](https://www.ask-codey.com/glossary/file-extension)
- [-WhatIf and -Confirm](https://www.ask-codey.com/glossary/whatif-and-confirm)

## Cheat sheets

- [Making Folders and Files: New-Item](https://www.ask-codey.com/cheat-sheets/powershell-new-item-cheat-sheet)

## Related

- [Copy and Move: Copy-Item and Move-Item](https://www.ask-codey.com/lessons/powershell-copy-and-move)
- [Looking Around: Get-ChildItem](https://www.ask-codey.com/lessons/powershell-looking-around)

Source: https://www.ask-codey.com/lessons/powershell-new-item
