ZTree.com  | ZEN  | About...  

 Index   Back

[Help!] batch - how to find if it is a Drive or Dir or File   [Help!]

By: Ryan       
Date: May 15,2020 at 13:15

::how to find if it is a Drive or Dir or File

method 1=

IF "%3"=="\" IF "%4"=="" GOTO :DoDrive
SET ZTMode=File
REM #ZTIfDir SET ZTMode=Dir
IF [%%ZTMode%%]==[File] GOTO :DoFile
IF [%%ZTMode%%]==[Dir] GOTO :DoDir
GOTO :END

-------------------------------------

method 2=

IF "%3"=="\" IF "%4"=="" (
SET P1=Adrive
SET P2=Bdrive
SET P3=%2
)
GOTO :MODE

SET ZTMode=File
REM #ZTIfDir SET ZTMode=Dir
IF [%%ZTMode%%]==[File] (
SET P1=Adir
SET P2=Bdir
SET P3=%1
)
IF [%%ZTMode%%]==[Dir] (
SET P1=Afile
SET P2=Bfile
SET P3=%1
)
GOTO :MODE

REM ------------------------------
:MODE

ECHO.
ECHO %P1%
ECHO %P2%
ECHO %P3%
ECHO.
PAUSE


i can do this with method 1, but it has too many GOTO's
i like to know how i can do with method 2. is there a way?
i am stuck with this line IF [%%ZTMode%%]==[File],it wont take multiple lines.

269 views      
 

Messages in this Thread

 
95,108 Postings in 11,994 Threads, 350 registered users, 61 users online (0 registered, 61 guests)
Index | Admin contact |   Forum Time: Oct 23, 2020 - 8:07 am UTC  |  Hits:34,843,894  (0 Today )
RSS Feed