Hello_World
Hello_World

Reputation: 35

nested mkdir inside directory with spaces

This command:

mkdir "watermelon fun"\example

Outputs the following:

PS C:\Users\Andrés\temp> mkdir "watermelon fun"\example
mkdir : No se encuentra ningún parámetro de posición que acepte el argumento     '\example'.
En línea: 1 Carácter: 1
+ mkdir "watermelon fun"\example
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [mkdir],     ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,mkdir

Is there a way you can create a nested directory, being one of these a multiple word directory?

Upvotes: 3

Views: 1467

Answers (2)

Martin Brandl
Martin Brandl

Reputation: 58931

Consider using the Join-Path cmdlet to combine a path.

$path = join-path 'watermelon fun' 'example'
New-Item -Path $path -ItemType Directory -Force

Upvotes: 2

sodawillow
sodawillow

Reputation: 13176

You have to surround the complete path with quotes:

mkdir "watermelon fun\example"

Upvotes: 2

Related Questions