john c. j.
john c. j.

Reputation: 1175

One-liner doesn't perform second action

I'm trying to implement this simple algorithm:

  1. If there are no directory "Abc", then create it.

  2. Despite of the existing or non-existing of Abc, echo me "Hello".

But for some reason, I see greeting only if Abc wasn't created yet.

if not exist "Abc" mkdir Abc & echo Hello

How I may fix it?

Upvotes: 0

Views: 37

Answers (1)

lit
lit

Reputation: 16236

cmd is putting the & portion with the mkdir. If the directory is not created, the & portion is never executed.

(if not exist "Abc" mkdir Abc) & echo Hello

Upvotes: 2

Related Questions