|go to command prompt and type:|
this gives a good idea of what's going on. basically the tilde-n says to extract the last element from a path-string.
(actually, should probably have put: %%~nxa in my fix, in case the directory has an extension). tokens are the elements of any given string, and are like words in a sentence separated by delimiters (like words have spaces, or commas, etc. between them.) batchscript defaults to tokenizing on spaces and tabs, and so i put tokens=* (that is, * means "all") in order to get the whole string instead of just the first "word", in case your path had spaces (yech!) in it.