General discussion

  • Creator
    Topic
  • #4219859

    Batch File Directories with Spaces

    Locked

    by jasongammacom ·

    Tags: 

    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.

All Comments

  • Author
    Replies
    • #4219901
      Avatar photo

      Reply To: Batch File Directories with Spaces

      by kees_b ·

      In reply to Batch File Directories with Spaces

      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 reply was modified 10 months, 2 weeks ago by Avatar photokees_b.
      • This reply was modified 10 months, 2 weeks ago by Avatar photokees_b.
Viewing 0 reply threads