Search code examples
batch-filemkdir

I cannot make a new directory in this file path in my batch file?


I am doing a project that lets you select a file, then it moves it to a certain place. But I am having a problem because I want to to check for a certain folder and if that is no then it creates one. At the moment I have.

if exist C:\Program Files (x86)\Steam\steamapps\common\main folder\Dropzone goto next

if not exist C:\Program Files (x86)\Steam\steamapps\common\main foler\Dropzone
mkdir C:\Program Files (x86)\Steam\steamapps\common\main folder\Dropzone

:next

But I am having trouble, I understand that I you need '^' in between the spaces or something but I have tried that and it has not worked.

Has anyone got any suggestions? Thanks,


Solution

  • Try this:

    if not exist "C:\Program Files (x86)\Steam\steamapps\common\main foler\Dropzone" (
    mkdir "C:\Program Files (x86)\Steam\steamapps\common\main folder\Dropzone"
    )
    :next
    

    You need the double quotes.

    Mona