-
-
Save dhtml/bc4ccc5c9b2425712bf75347b4cd2c7f to your computer and use it in GitHub Desktop.
How to get filename, dirname, and basename in bat?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set filepath="C:\some path\having spaces.txt" | |
for /F "delims=" %%i in (%filepath%) do set dirname="%%~dpi" | |
for /F "delims=" %%i in (%filepath%) do set filename="%%~nxi" | |
for /F "delims=" %%i in (%filepath%) do set basename="%%~ni" | |
echo %dirname% | |
echo %filename% | |
echo %basename% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Excellent job, this helped me out just now.