parsing - Get last token from string in batch script -
i working on batch script, , need way remove lowest-level directory total path string. example, if have:
c:/dir1/dir2/dir3
i batch script homecoming "dir3." string, c:/dir1/dir2/dir3 passed in user , set variable "fullpath".
i looked on reply here, appeared similar problem, solutions there didn't create utilize of delimiters. and, closest i've gotten solving this code:
for /f "tokens=(some number) delims=\" %%a in ("%fullpath%") echo token=%%a
...this can echo token specify (i setting token variable, need right 1 first), don't know how many tokens there be, , want lastly 1 in string, next "\" character.
how can edit line of code homecoming final token in string?
for %%a in ("%fullpath%\.") set "lastpart=%%~nxa"
that is, utilize for
loop reference total path , retrieve name , extension of lastly element
parsing batch-file directory
No comments:
Post a Comment