Computing.Net > Forums > Programming > condition check in for loop

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

condition check in for loop

Reply to Message Icon

Name: gauravjee
Date: June 29, 2006 at 22:53:09 Pacific
OS: dos
CPU/Ram: 512
Product: Intel
Comment:

hi
thanks a tons for helping me earlier

I am stuck with a small problem

Thru the following code i am able to create the folders
but my problem is that i want to check before creating the folder that whether the folder exists or not

::** CODE START

@ECHO OFF
SET MM=%date:~4,-8%
SET DD=%date:~7,-5%
SET YYYY=%date:~-4,10%
SET FOLNAM=%YYYY%_%MM%
SET FOLNAM1=%YYYY%%MM%%DD%

for /f %%i in (j:\configfol.txt) do MD %%i\%FOLNAM%\%FOLNAM1%

::** CODE END


what i feel is that if i am able to run a if check inside the for loop i will be able to do it

but the problem is i dont know how to do it


Please help


Thanks

Gaurav



Sponsored Link
Ads by Google

Response Number 1
Name: uli_glueck
Date: June 29, 2006 at 23:22:57 Pacific
Reply:

This should work:
(Depends about your os. Standalone Dos doesn`t know the for /f statement.)

for /f %%i in (j:\configfol.txt) do call :SUB
%%i


:SUB %%i
if not exist %1\%FOLNAM%\%FOLNAM1%
MD %1\%FOLNAM%\%FOLNAM1%


The MD... line is the same as the if statement.
Computing net breaks the lines.

hope it helps
uli



0

Response Number 2
Name: gauravjee
Date: June 30, 2006 at 00:18:01 Pacific
Reply:

Thanks uli

Thanks

Gaurav


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: condition check in for loop

count in for loop in dos www.computing.net/answers/programming/count-in-for-loop-in-dos/16609.html

single per (.) in for loop batch www.computing.net/answers/programming/single-per-in-for-loop-batch-/17766.html

Variables in For loops, Batch www.computing.net/answers/programming/variables-in-for-loops-batch/17037.html