Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The windows %%f returns the full name of the file as 'filename.ext'


for /r %%f in (*.wav) do echo %%f

Is there a way to extract the filename without the extension from %%f?

share|improve this question
up vote 4 down vote accepted

Change echo %%f to echo %%~nf.

~n tells the cmd to expand f to equal only the filename, minus the extension.

share|improve this answer
Thanks mate! May I be so bold as to enquire how you acquired that little tid-bit? – Everyone Jul 17 '11 at 16:25
From the horse's mouth: Generally, anything Product related is going to be under Anything programming related is going to be under (Microsoft Developer's network). – surfasb Jul 17 '11 at 20:07
Very useful (+: Thank you! – Everyone Jul 17 '11 at 20:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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