Search code examples
parsingsubstringextractbatch-fileindexof

DOS batch: get last folder from relative path


I have the following values in a DOS batch file (for example...):

..\Apple\Jones  
..\Banana\Smith  
..\Pear\Wilson  

I need to extract the last name values ("Jones", "Smith", "Wilson") from each value. What one technique can I use that will always give me these substring values?


Solution

  • According to this topic : What is the best way to do a substring in a batch file?

    I suggest you to use

    %~n0