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 16,2020 at 01:19
In Response to: [Help!] batch - how to find if it is a Drive or Dir or File (Ben Kent)

AA=
SetLocal
Call :GetObjectType %1

echo ObjectType=%%ObjectType%%

pause
goto :eof
REM -------------------------------------------
: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
)
EXIT /B

AA= is not working, it always gives file as an answer.

167 views      
 

Messages in this Thread

 
95,065 Postings in 11,983 Threads, 350 registered users, 93 users online (0 registered, 93 guests)
Index | Admin contact |   Forum Time: Aug 4, 2020 - 7:07 pm EDT  |  Hits:32,847,964  (35,231 Today )
RSS Feed