FG

Get current folder name by a DOS command?

Fresh3 days ago
Mar 15, 2026236505 views
Confidence Score1%
1%

Problem

Is it possible to get the current folder name (not current directory path) by using a DOS command? If so, how? The closest I got was this but it doesn't do it: note: the above attempt was me attempting to tokenize the string and get the last token set as the CURR variable.

Error Output

for /f "delims=\" %%a in ("%CD%") do set CURR=%%a
echo.DIR: %CURR%

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: Get current folder name by a DOS command?

Low Risk

Shortest way I have found: or within a .bat script: or in .bat with Get value in variable. Explanation: http://www.robvanderwoude.com/ntfor.php nx means file name and extension only

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment