Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Possible Duplicate:
Get current folder name by a DOS command?

In my batch file, I have,

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

Prints the whole directory path.

C:\www\scritps\

I need to get scripts alone

share|improve this question
    
Answer already here. –  CharlieRB Dec 20 '11 at 14:48
add comment

marked as duplicate by studiohack Dec 20 '11 at 15:15

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer

up vote 4 down vote accepted

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

for %%* in (.) do @echo %%~n*
share|improve this answer
    
that's fantastic (of course, * can be replaced with a letter), out of interest, howcome you used * ? btw, FWIW for any that don't know, # and ? work too. %%? and %%# –  barlop Dec 20 '11 at 14:44
1  
I didn't want to use something like "x" (or another letter) because I didn't want the original poster to get confused at the "~nx" part. But you're right, you could substitute any letter there. Coding in DOS .bat is so archaic that it's sometimes difficult to see what's going on. –  BryceAtNetwork23 Dec 20 '11 at 15:03
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.