Batch File Directories with Spaces - TechRepublic
General discussion
March 4, 2024 at 10:06 AM
jasongammacom

Batch File Directories with Spaces

by jasongammacom . Updated 2 years, 3 months ago

Hello,

I am struggling with what will probably be a pretty straight forward solution.

Basically i have created a small Batch File that should allow the end user to input some information upon prompt and then the code should create the new “Main Folder” and then the Subsequent Sub folders.

This all works well, UNTIL, i have SPACES in my input information:

@echo off

set /p QuoteReference=What is the Quote Reference?
set /p SiteName=What is the Site name?

set NewFolder=”%QuoteReference% – “%SiteName%””

MD %NewFolder%

CD %NewFolder%

MKDIR “1. Tender Pack”
MKDIR “2. Tender Specification”
MKDIR “3. Accommodation Schedule”
MKDIR “4. Scope of Works & ER’s”
MKDIR “5. Tender Meeting Minutes”
MKDIR “6. Tender Proposal”
MKDIR “7. Calculations & SOR”
MKDIR “8. Contract & Purchase Order”
MKDIR “9. Drawings & Schematics”

As soon as there is a Space in either the Sitename or QuoteReference fields – The entire code falls apart and it just creates a mish mash bunch of folders?

Any guidance would be greatly appreciated.

This discussion is locked

All Comments