Windows batch - loop over folder string and parse out last folder name
- by Tim Peel
Hi,
I need to grab the folder name of a currently executing batch file. I have been trying to loop over the current directory using the following syntax (which is wrong at present):
set mydir = %~p0
for /F "delims=\" %i IN (%mydir%) DO @echo %i
Couple of issues in that I cannot seem to pass the 'mydir' variable value in as the search string. It…