I figured something out today - HOW TO: Separate filename and directory from a path.
This is really fun! The idea I had was to allow me to drag and drop a file onto a batch file and have it spit out the MD5 code for it. Simple right?... hardly...
Here's the code...
This is really fun! The idea I had was to allow me to drag and drop a file onto a batch file and have it spit out the MD5 code for it. Simple right?... hardly...
Here's the code...
@echo off
REM Check to see if filename is specified
if %1.==. goto end
set filename=%1
REM Remove double quotes from filename
for /f "tokens=1* usebackq delims=?" %%i IN ('%filename%') DO (
set filename=%%~i
)
REM Build directory path
set dir_path=
:loop
for /f "tokens=1,2* usebackq delims=\" %%i IN ('%filename%') DO (
set dir_path=%dir_path%%%i\
if not %%k.==. (
set filename=%%j\%%k
goto loop
)
set filename=%%j
)
echo DIRPATH:%dir_path%
echo FILENAME:%filename%
pause
:end
Comments