I need to find the folder name of the batch file that I am executing. All the other approaches provide me with the full path.
I only need the parent folder name. Also, the other mentioned approaches use looping, which is quite lengthy and verbose for my needs.
Is there any method for finding out the parent folder name directly through the % parameters(or their combinations) ?
I need to find the folder name of the batch file that I am
Share
The direct answer to your question is “No”. There is no direct method using only expansion modifiers without using a FOR loop or CALL.
The referenced thread in your question pretty much has everything you need.
Here are two optimized techniques that are very similar to what has already been posted. Method1 should be the fastest:
Edit – I further optimized by removing the substring operation.
Edit2 – I substituted simple FOR in place of FOR /F