I am new to batch programming. I want to find filename and its extension from a String. I see answers where path is in for variable e.g.
for /f %%a in ('dir /B') do (
file_name= %%~nxa
)
But following code does not work.
stringvar="c:/folder1/folder2/abc.txt"
file_name=%%~nxstringvar
I tried many permutation and combination with stringvar and %% and ~nx in expression. But I did not get filename.
Please consider below code to understand the need.
stringvar="c:/folder1/folder2/abc.txt"
filename=getFileName(stringvar)
Any answer or suggestion is most welcome. Thankig you in advance