📁 How to Create Employee Folders in Bulk from Excel and Move Files Automatically (Windows CMD)
PC Tips

📁 How to Create Employee Folders in Bulk from Excel and Move Files Automatically (Windows CMD)

By Tech With Tez Mar 19, 2026 15 Views

Managing employee documents manually can be time-consuming. This guide explains a quick and efficient method to:

  1. Create folders in bulk using an Excel file

  2. Automatically move employee files into their respective folders using CMD


📄 Step 1: Prepare Your Excel File

Create an Excel file named employees.xlsx with the following format:

Name
JohnDoe
JaneSmith
AliceBrown
RobertKhan
PriyaMehra

Important Notes:

  • The column header must be Name

  • Each row should contain one employee name

  • Ensure names match the folder naming format

👉 Save this file as CSV (Comma Delimited): employees.csv


📁 Step 2: Create Staff Folder

  • Go to your Desktop

  • Create a folder named:
    Staff Folder


⚙️ Step 3: Create Folders in Bulk (PowerShell)

  1. Open PowerShell

  2. Run the following script:

$csvPath = "$env:USERPROFILE\Desktop\employees.csv"
$targetFolder = "$env:USERPROFILE\Desktop\Staff Folder"

Import-Csv -Path $csvPath | ForEach-Object {
$folder = "$targetFolder\$($_.Name)"
if (!(Test-Path $folder)) {
New-Item -Path $folder -ItemType Directory
}
}

✅ This will create folders like:

  • Staff Folder\JohnDoe

  • Staff Folder\JaneSmith


📂 Step 4: Prepare Files for Sorting

  • Place all employee files in a folder, e.g.:
    Desktop\UnsortedDocs

Example File Names:

  • JohnDoe_ID.pdf

  • JaneSmith_Resume.docx

  • PriyaMehra_Document.jpg


🚀 Step 5: Move Files Using CMD (.bat File)

Create a Batch File:

  1. Open Notepad

  2. Paste the following code:

@echo off
set "source=%USERPROFILE%\Desktop\UnsortedDocs"
set "destination=%USERPROFILE%\Desktop\Staff Folder"

cd /d "%source%"

for %%F in (*) do (
for /d %%D in ("%destination%\*") do (
echo %%~nF | findstr /b /i "%%~nxD" >nul
if not errorlevel 1 (
move "%%F" "%%D\"
echo Moved %%F to %%D
)
)
)
pause
  1. Save as: move_files.bat

  2. Double-click the file to run


🔍 How It Works

  • The script checks each file name in UnsortedDocs

  • If the file name starts with an employee name, it:

    • Finds the matching folder

    • Moves the file into that folder

Example:

  • JohnDoe_Certificate.pdfStaff Folder\JohnDoe

  • JaneSmith_ID.jpgStaff Folder\JaneSmith


⚠️ Tips & Best Practices

  • Ensure file names start with employee names

  • Avoid special characters in folder names

  • Always backup your files before running scripts

  • Test with a few files first before bulk execution