Created
December 12, 2025 16:29
-
-
Save paulorenanmelo/2a37c2b8a426ef784961f06ba45219b1 to your computer and use it in GitHub Desktop.
How to manipulate a string with a path from a variable in batch to get drive, path, name, extension, and dir+name.
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
| @echo off | |
| set "myvar=C:\test folder\subfolder\test file.txt" | |
| for %%Q in ("%myvar%") do ( | |
| echo full: %%~fQ | |
| echo drive: %%~dQ | |
| echo path: %%~pQ | |
| echo name: %%~nQ | |
| echo ext: %%~xQ | |
| echo dir+name: %%~dpnQ | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment