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.

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

e.g.

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
add comment

1 Answer

up vote 1 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
1  
From the horse's mouth: technet.microsoft.com/en-us/library/bb490909.aspx. Generally, anything Product related is going to be under technet.microsoft.com. Anything programming related is going to be under msdn.microsoft.com (Microsoft Developer's network). –  surfasb Jul 17 '11 at 20:07
    
Very useful (+: Thank you! –  Everyone Jul 17 '11 at 20:10
add comment

Your Answer

 
discard

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.