How to Create Folders from an Excel List

Excel can’t create folders by itself, but it can quickly build the commands that do. Put the folder names in column A, and in B2 type ="md """&A2&"""", which produces lines like md “Client A”. Copy the formula down and copy the results. Then open Command Prompt in the folder where you want the new folders and paste. Windows creates one folder per name in seconds. PowerShell and a short VBA macro are two other options. Here’s each method.

How to create folders from an Excel list: build md commands with a formula and run them in Command Prompt, use PowerShell with copied names, or run a VBA macro
Three ways to turn a column of names into folders. This is a drawing, not a screenshot.

Before you start: clean the names

Folder names can’t contain these characters: \ / : * ? ” < > |. Names also shouldn’t end with a space or a full stop. Remove stray spaces with =TRIM(A2), and replace forbidden characters with Find and Replace (Ctrl + H). See how to remove characters from a cell in Excel.

Method 1: Build md commands and run them in Command Prompt

  1. List the folder names in column A, starting at A2.
  2. In B2, type ="md """&A2&"""" and copy it down. The extra quotation marks wrap each name in quotes, so names with spaces work.
  3. Select the results in column B and press Ctrl + C.
  4. In File Explorer, open the folder where the new folders should go. Click the address bar, type cmd and press Enter. Command Prompt opens in that folder.
  5. Right-click in the Command Prompt window to paste, and press Enter after the last line if needed.

The folders appear immediately. If a folder already exists, Command Prompt shows a message for that one and carries on with the rest.

Subfolders

md creates nested folders in one go. If column A holds a client and column B a year, use ="md """&A2&"\"&B2&"""" to create Client A\2026, including the parent folder.

Save it as a batch file

To reuse the list, paste the commands into Notepad and save the file as make-folders.bat in the target folder. Double-click it to run. Check the commands before running any batch file.

Method 2: PowerShell

  1. Copy the folder names from column A (just the names, no formula needed).
  2. In File Explorer, open the target folder, type powershell in the address bar and press Enter.
  3. Run: Get-Clipboard | Where-Object { $_.Trim() } | ForEach-Object { New-Item -ItemType Directory -Name $_.Trim() -Force }

This reads the names straight from the clipboard, skips blank lines, and creates each folder. -Force stops errors if a folder already exists.

Method 3: A VBA macro

A macro lets you create folders from inside Excel with one click.

  1. Press Alt + F11 to open the VBA editor, then go to Insert > Module.
  2. Paste this code, changing the base path to your own folder (keep the backslash at the end):
Sub MakeFolders()
    Dim c As Range, basePath As String
    basePath = "C:\Projects\"
    For Each c In Selection
        If Len(Trim(c.Value)) > 0 Then
            If Dir(basePath & Trim(c.Value), vbDirectory) = "" Then
                MkDir basePath & Trim(c.Value)
            End If
        End If
    Next c
End Sub
  1. Close the editor, select the cells with the folder names, and press Alt + F8. Choose MakeFolders and click Run.
  2. Save the workbook as Excel Macro-Enabled Workbook (.xlsm) if you want to keep the macro.

The macro skips blank cells and folders that already exist. If macros are blocked, see how to enable macros in Excel and how to run macros in Excel.

Which method should you use?

Method Best for
md commands One-off jobs, with no macros or scripting
PowerShell Quick jobs straight from a copied list
VBA macro Jobs you’ll repeat from the same workbook

Troubleshooting

“The syntax of the command is incorrect”

A name contains a forbidden character, or the quotation marks are missing. Check the formula in column B.

Access is denied

You don’t have permission to create folders in that location. Choose a folder in your own Documents, or a shared folder you can write to.

Folders are created in the wrong place

Command Prompt and PowerShell create folders in the current folder shown in the prompt. Open them from the target folder’s address bar, as described above.

Related guides

Summary

  1. Clean the names in Excel.
  2. Build commands with ="md """&A2&"""", then paste them into Command Prompt opened in the target folder.
  3. Or copy the names and run one PowerShell command.
  4. Or use a VBA macro for a repeatable, one-click option.

Related: How to Create an Organizational Chart in Excel from a List.

Get Our Free Newsletter

How-to guides and tech deals

You may opt out at any time.
Read our Privacy Policy