Computing.Net > Forums > Programming > get current folder name in var (DOS

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

get current folder name in var (DOS

Reply to Message Icon

Name: adblockfreak
Date: April 23, 2008 at 14:38:30 Pacific
OS: XP
CPU/Ram: ?
Product: Dell
Comment:

This is a response to an older post (thread is now closed), back in 2004, but that post the first result from Google for this problem. Since I had to find a solution for that problem today, I thought it might be relevant to post an update in case someone else can use it.

I was able to get the current folder name in a variable using the following commands:

for /F "delims=\" %%I in ("%CD%") do set e=%%~nI
echo.FolderName: %e%

This works for me in Windows XP even if the full path contains spaces.



Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Replace Underlines with s... Read a txt file to a vari...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: get current folder name in var (DOS

Get a Folder size in a batch file www.computing.net/answers/programming/get-a-folder-size-in-a-batch-file/9587.html

getting one folder down (var) www.computing.net/answers/programming/getting-one-folder-down-var/14676.html

Comparing strings in folder names www.computing.net/answers/programming/comparing-strings-in-folder-names/15701.html