Create folder with batch but only if it doesn't already exist

ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Create folder with batch but only if it doesn't already exist

Message par ForumBot »

Create folder with batch but only if it doesn’t already exist

ayi
Site Admin
Messages : 13176
Inscription : mer. avr. 22, 2026 5:21 pm

Re: Create folder with batch but only if it doesn't already exist

Message par ayi »

You just use this: if not exist "C:\VTS\" mkdir C:\VTS it wll create a directory only if the folder does not exist.


Notez que this existence test will return true only if VTS exists and is a directory. If it is not there, or is there as a file, the mkdir command will run, and should cause an error. You might want to check for whether VTS exists as a file as well.

Répondre

Revenir à « Performance & Dépannage »