How to extract filename from full path to bit?
The variable %result%
contains the path "D:\My Folder1\My Folder 2\My Folder 3\The Important File.txt"
. I want to store The Important File
in some other variable. That is, I want to extract the filename (without extension) from the full path.
+1
Deb
source
to share
2 answers
This should give you what you need.
@echo off
for %%a in ("%result%") do set "newvariable=%%~na"
+2
foxidrive
source
to share
You will find a solution here: Get filename from full or relative path knowing this parameter is not a package parameter
here: Get filename from path string?
here: In batch mode: read only filename from variable with path and filename
Please look for existing questions before creating duplicates.
+2
Corvusoft
source
to share