Thanks to other posts here, I know how to make a batch file parse a dropped file into a path and a filename, like this:
@echo off
setlocal EnableDelayedExpansion
FOR %%a IN (%*) DO (
if exist %%a (
set DRVPATH="%%~dpa"
set FILEEXT="%%~nxa"
)
)
echo DRVPATH: %DRVPATH%
echo FILEEXT: %FILEEXT%
This works perfectly if I drop a file on the batch file. But if I drop a directory onto it, then it interprets the name of the directory as the filename (my %FILEEXT% variable).
Is it possible to make the batch file test whether %FILEEXT% is actually a directory? If I drop a directory on the batch file, I want the %DRVPATH% variable to contain the full path including the directory name, and I want the %FILEEXT% variable to be empty.
Any help in sorting this out will be gratefully received.