FG
💻 Software

Get current folder name instead of current path in windows batch file

Fresh5 days ago
Mar 15, 202619102 views
Confidence Score0%
0%

Problem

Possible Duplicate: Get current folder name by a DOS command? In my batch file, I have, Prints the whole directory path. I need to get alone

Error Output

SET currentFolder=%CD%
echo "%currentFolder%"

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 instead of current path in windows batch file

Low Risk

There really isn't an easy way to do it. This works in a .bat file:

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment