Discussion Locked

Batch File Directories with Spaces

0 helpful
1 reply
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

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.

1 reply

by kees_b edited

Tip: set echo on in stead of off, and then you'll see that you have to add quotes in the lines with MD and CD or maybe (depending on what you see) in the line that makes the newfolder variable.

This discussion is closed to new replies.