Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Create File Folders from Excel: Step-by-Step Guide

· 5 min read · Home Tech

In this article
  1. Why Create Folders from Excel?
  2. Method 1: Using a Batch File (Windows)
  3. Method 2: Using PowerShell (Windows)
  4. Method 3: Using a Macro (Excel VBA)
  5. Handling Spaces and Special Characters
  6. Common Mistakes and Troubleshooting
  7. Alternatives and Automation Tools
  8. Frequently Asked Questions

Yes, you can create file folders directly from an Excel list, and the most reliable method uses a simple batch script generated from your data. You don’t need any special software—just Excel, Notepad, and Windows File Explorer (or Finder on a Mac with a different script). This guide walks you through the exact steps, explains why it works, and covers common pitfalls so you can automate folder creation in minutes.

Why Create Folders from Excel?

Manually creating dozens or hundreds of folders is tedious and error-prone. If you have a list of project names, client IDs, employee names, or date ranges, Excel can drive the process. Instead of right-clicking and typing each name, you generate a script that tells your operating system to create every folder at once. This is especially useful for:

  • Organizing files by project, month, or category
  • Setting up a standard folder structure for new employees or clients
  • Preparing directories for batch processing or data imports

Method 1: Using a Batch File (Windows)

The most common approach on Windows is to create a .bat file that uses the mkdir command. Here’s how to do it step by step:

  1. Open your Excel file and put the folder names in column A, starting at A1.
  2. In cell B1, enter the formula: ="mkdir "&"""&A1&"""" (this wraps each name in quotes to handle spaces and special characters).
  3. Drag the fill handle down to copy the formula for all folder names.
  4. Copy column B and paste it into a new Notepad file.
  5. Save the Notepad file with a .bat extension (e.g., create_folders.bat). Make sure “Save as type” is set to “All Files” to avoid saving as .txt.
  6. Place the .bat file in the directory where you want the folders to appear.
  7. Double-click the .bat file. The folders will be created instantly.

Important: The .bat file must be in the target folder, or you must include the full path in the script (e.g., mkdir "C:\Users\YourName\Documents\Project").

Method 2: Using PowerShell (Windows)

PowerShell is more powerful and handles spaces better without extra quoting. Here’s a cleaner method:

  1. In Excel, put folder names in column A.
  2. In cell B1, enter: ="New-Item -ItemType Directory -Path '"&A1&"'"
  3. Copy column B into Notepad and save as a .ps1 file.
  4. Open PowerShell as administrator (if needed) and run: Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser (only once).
  5. Navigate to the folder containing your script and run it: .\create_folders.ps1

PowerShell also allows you to create nested folders easily by including backslashes in the name, like 2024\January.

Method 3: Using a Macro (Excel VBA)

If you prefer to stay inside Excel, you can use a simple VBA macro. This method is ideal if you frequently need to create folders from lists.

  1. Press Alt + F11 to open the VBA editor.
  2. Go to Insert > Module.
  3. Paste the following code:
Sub CreateFolders()
    Dim rng As Range
    Dim cell As Range
    Set rng = Range("A1:A" & Range("A" & Rows.Count).End(xlUp).Row)
    For Each cell In rng
        If cell.Value <> "" Then
            MkDir ThisWorkbook.Path & "\" & cell.Value
        End If
    Next cell
End Sub
  1. Close the editor, then press Alt + F8, select CreateFolders, and click Run.

This creates folders in the same directory as the Excel file. You can modify the path to any location by changing ThisWorkbook.Path to a hardcoded path like "C:\MyFolders".

Handling Spaces and Special Characters

Folder names with spaces, ampersands (&), or apostrophes can break batch scripts. The quoting in Method 1 ("""") solves this. For PowerShell, single quotes around the path work, but if the name itself contains a single quote, double the quote (e.g., ''). VBA’s MkDir handles spaces fine but will fail if the folder name contains invalid characters like :, *, ?, ", <, >, |. Always clean your list before running the script.

Common Mistakes and Troubleshooting

  • Wrong file extension: Notepad saves as .txt by default. Use “All Files” or rename manually.
  • Path not found: The script runs in the current directory. If your .bat is elsewhere, folders appear there, not where you expect.
  • Duplicate names: Windows won’t create a folder if it already exists; the script will simply skip or error. Use a formula to remove duplicates first.
  • Excel formula errors: If your folder names contain quotes, the formula may break. Use SUBSTITUTE to replace quotes with nothing.
  • PowerShell execution policy: If you get a “running scripts is disabled” error, you need to change the execution policy as shown earlier.

Alternatives and Automation Tools

If you don’t want to write scripts, you can use:

  • Excel’s built-in “New Folder” shortcut: Not automated, but you can create multiple folders manually by selecting multiple cells and pressing Ctrl+Shift+N (Windows) – though this only creates one folder at a time.
  • Third-party file organizer apps: Some tools allow bulk folder creation from CSV, but they often require a paid license.
  • Power Automate (Microsoft): Can create folders in OneDrive or SharePoint from an Excel table, but requires a Microsoft 365 subscription.

Frequently Asked Questions

Can I create subfolders from Excel?

Yes. In a batch script, use mkdir "parent\child" to create nested folders. In VBA, you may need to create the parent first if it doesn’t exist, or use MkDir with the full path. In PowerShell, New-Item -ItemType Directory -Path "parent\child" creates the entire path automatically.

How do I create folders on a Mac from Excel?

Use a shell script instead of .bat. In Excel, create a column with ="mkdir -p '"&A1&"'", copy to TextEdit, save as a .command file, then run it in Terminal. Alternatively, use AppleScript via a macro, but that’s more complex.

What if my folder names have leading/trailing spaces?

Excel may not trim them automatically. Use =TRIM(A1) in a helper column to remove extra spaces before generating the script. Otherwise, the folder will include the spaces, which can cause confusion later.

Can I create folders from a CSV file?

Yes. Open the CSV in Excel, follow the same steps, or use a command-line tool like for /f %i in (list.csv) do mkdir "%i" in Windows. This avoids Excel entirely.

Is there a way to create folders and subfolders in one go with a formula?

Yes, in Excel you can combine names with a slash (e.g., ="mkdir """&A1&"\"&B1&"""" if A1 is parent and B1 is child). This creates the full path in one command, but the parent folder must exist or the script will fail. Use mkdir with the full path and it will create all levels.

Why does my batch file close immediately?

If the script runs successfully, the window closes instantly. To see errors, add pause at the end of the .bat file. That way, the window stays open so you can read any error messages.