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.

895 views      
Thread locked
 

Messages in this Thread

 
96,637 Postings in 12,231 Threads, 350 registered users, 104 users online (0 registered, 104 guests)
Index | Admin contact |   Forum Time: Mar 28, 2024 - 10:45 pm UTC  |  Hits:62,382,923  (35,320 Today )
RSS Feed