Batch file drive loop

April 6, 2009 at 07:00:21
Specs: DOS
hi i'm making a batch file that detects HDD partitions and deletes some directory's.
but i'm stuck using the loop cant realy find out how to make it work.
any help would be appreciated.


:the Batch
:CDRIVE
CLS
FOR %%P IN (C D E F G H I J K L M N O P Q R S T U V W X Y Z) DO IF EXIST %%P:\nul echo. %%P is aangesloten
ECHO.
ECHO ------------------------------------------------------------------------
FOR %%P IN (C) DO IF NOT EXIST %%P:\nul GOTO DDRIVE
FOR %%P IN (C) DO IF EXIST %%P:\nul echo. Wilt u naar %%P gaan?
set station={j,n}
set /p station= ja of nee (j/n):
IF '%station%'=='J' GOTO CROOT
IF '%station%'=='j' GOTO CROOT
IF '%station%'=='N' GOTO DDRIVE
IF '%station%'=='n' GOTO DDRIVE

if anyone could tell me at least how to loop this so that it goes to the drive where the yes falls


See More: Batch file drive loop

Report •


#1
April 6, 2009 at 08:56:43
First of all post your actual operating system, as DOS is NOT the environment you are running; you run under Windows 2K/XP as the set /P statement reveals. What you believe to be DOS is the NTVDM emulator and your statements are interpreted by cmd.exe NOT command.com: in one word your script is NT batch.

So stated the code you posted may be rearranged so

:: The Batch
@echo off & setlocal EnableDelayedExpansion
CLS
FOR %%P IN (C D E F G H I J K L M N O P Q R S T U V W X Y Z) DO (
  IF EXIST %%P:\nul (
    echo. %%P is aangesloten
    ECHO.
    ECHO ----------------------------------------- 
    echo. Wilt u naar %%P gaan?
    set station={j,n}
    set /P station= ja of nee (j/n): 
    IF  /I "!station!"=="J"  (
       echo.  Response is JA
       echo. Here add your code
    )
  )
)

Type e.g. set /? or If /? to get a short on-line help. Another tip. please post ONLY in English (the text in the script body too) as this is the only language allowed in Computing.net Forum.


Report •

#2
April 6, 2009 at 11:13:23
wel it has to run under dos 2 have to point out some flaws yet

and sry to tell but this batch doesnt really run yet trying to make it run


Report •

#3
April 6, 2009 at 13:25:45
My script is NT batch and requires Windows XP/2K to run. If you need a plain DOS batch you have to give up the SET /P statement as it is supported in FreeDOS but NOT in MS-DOS.

There is a workaround and I can give you the required code in pure DOS, but I need you confirm to me you have to run in real DOS environment.


Report •

Related Solutions

#4
April 7, 2009 at 05:11:08
Mate, a good start would be to type 'ver' which is short for version into your command prompt... post the results here and the pros will be able to help you!

ciao


Report •

#5
April 7, 2009 at 07:00:53
it has to run under XP but under DOS to
version of my PC is 5.1.2600

Report •

#6
April 7, 2009 at 07:06:14
N3oblaster: it has to run under XP but under DOS
These are mutually exclusive, unless you have some 20 year old PCs around.

Report •

#7
April 7, 2009 at 09:48:27
I feel sorry for the pros!

Report •

#8
April 8, 2009 at 01:40:25
I think there's a bit of confusion in this area now let me explain it as good as i can.

the batch i am making must be able run under XP and DOS.
Why ??
Because someone has a xp machine standing which is being modified so that it can run DOS Commands, so my job for him was to make a batchfile that can run under DOS & XP to select a drive and execute the commands that are already done.


Report •


Ask Question