Check if input is a file or folder
问题 I have a command like this: set /p txtfile=Write destination to the .txt file: now i need to know if the file really exists so: if exist %txtfile% echo file found. it works, but if the user writes me C:\ it will display "file found" to. I want to know is there a way to know a file extension using batch, any ideas? 回答1: You can identify it as a file using TYPE. However, it might not be the best way if it is a large file. SET "DIR_ITEM=C:\Windows" TYPE "%DIR_ITEM%" 1>NUL 2>&1 IF ERRORLEVEL 1 (