Reputation: 173
How would I go about checking if a variable is a .txt file?
My code isn't working:
if /I "%ph2file%" NEQ "*.txt" echo This file is not a .txt file.
Upvotes: 0
Views: 154
Reputation: 56238
the "quick and dirty" way (check last four characters):
if /i "%ph2file:~-4%" neq ".txt" echo no .txt file
the "clean" way (check the extension):
for %a in ("%ph2file%") do echo if "%~xa" neq ".txt" echo no .txt file
Upvotes: 3