1.

Solve : How to check if a Directory already exists...?

Answer»

Would the syntax:

Code: [SELECT]CD \Program Files
IF DIR ALEC NIL THEN MD Alec
ELSE {Codeing here}
work?Welcome to the CH forums.

If you are in the root of c:

Try:
Code: [Select]cd program files
if not exist alec (md alec
   ) else (
   more coding here....
)


Quote

CD \Program Files
IF not exist ALEC\ (md alec) ELSE (
{Codeing here}
)

it's \ that distinguishs a folder from a file Quote from: Prince_ on December 07, 2008, 05:23:16 AM
Quote
CD \Program Files
IF not exist ALEC\ md alec
ELSE {Codeing here}
Unfortunately, ELSE isn't a command. Quote from: Carbon Dudeoxide on December 07, 2008, 05:26:06 AM
Quote from: Prince_ on December 07, 2008, 05:23:16 AM
Quote
CD \Program Files
IF not exist ALEC\ md alec
ELSE {Codeing here}
Unfortunately, ELSE isn't a command.

Careless Quote from: Prince_ on December 07, 2008, 05:23:16 AM
Quote
CD \Program Files
IF not exist ALEC\ (md alec) ELSE (
{Codeing here}
)

it's \ that distinguishs a folder from a file

So what? You cannot have a file and a folder with the same name in the same folder. so what is your point?
if there is a file named alec, then the code snippets below won't work.

Code: [Select]CD \Program Files
IF not exist ALEC (md alec) ELSE (
{Codeing here}
)



ACTUALLY,the best codes would be :

Code: [Select]CD \Program Files
IF not exist ALEC\ ((if exist alec del alec) & md alec) ELSE (
{Codeing here}
)yes, because it's always important to delete possibly vital data in the better INTEREST of a proper batch file.You really cannot get any simpler than:

Code: [Select]cd Program Files
if not exist ALEC (
   md ALEC
) else (
   codes
   here
)
Quote
actually,the best codes would be :

Code: [Select]
CD \Program Files
IF not exist ALEC\ ((if exist alec del alec) & md alec) ELSE (
{Codeing here}
)

Quote from: BC_Programmer on December 07, 2008, 06:55:02 PM
yes, because it's always important to delete possibly vital data in the better interest of a proper batch file.

LOL   The price of fame!  Where did the last 7 years CORPORATE tax records go?


Discussion

No Comment Found