ZTree.com  | ZEN  | About...  

 Index   Back

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

By: Ben Kent       
Date: May 15,2020 at 17:31
In Response to: [Help!] batch - how to find if it is a Drive or Dir or File (Ryan)

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

Maybe something like this, its pure cmd, so you will need to add extra % in :GetObjectType for use ZTree F9 menu

==========================
SetLocal

Call :GetObjectType %1

echo ObjectType=%ObjectType%
REM Any other code here

goto :eof

:GetObjectType
Set ObjectType=
Set "Object=%~1"
If ":"=="%Object:~1,2%" (
Set ObjectType=Drive
goto :eof
)
Set Attributes=
for %%I in (%1) do Set Attributes=%%~aI
If "d"=="%Attributes:~0,1%" (
Set ObjectType=Directory
) Else (
Set ObjectType=File
)
goto :eof
==========================

206 views      
 

Messages in this Thread

 
95,078 Postings in 11,987 Threads, 350 registered users, 159 users online (1 registered, 158 guests)
Index | Admin contact |   Forum Time: Aug 14, 2020 - 10:01 pm EDT  |  Hits:33,125,879  (25,641 Today )
RSS Feed