1.

Solve : How can a .BAT file distinguish a file from a folder??

Answer»

When an 'if exist' command tells me that ENTITY does exist, how do I TELL WHETHER ENTITY is a file or a folder?
This little snippet may HELP:

Code: [Select]echo off
set /p fname=Enter file name:
for %%v in ("%fname%") do (
  if exist %%~sv\nul (echo "%fname%" IS a directory) else (echo "%fname%" is NOT a directory)
)

The code will PROMPT for user INPUT. Feel free to tweak the code as you see fit.

Good luck. Code: [Select]for /f "delims=" %%A in ("%entity%") do set attribs=%%~aA
if "%attribs:~0,1%"=="d" echo %attribs% is a directory



Discussion

No Comment Found