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 bare file names recursively in command prompt

I would like to recursively list all files in a directory, showing filenames only (without extensions and without the full paths). I'm using Windows/DOS.

The closest I could get with dir was dir /s /b, but it lists full paths and also shows the extensions.

Well, perhaps I could live with the extensions, but I must get rid of the paths!

Any ideas?

share|improve this question

marked as duplicate by Ƭᴇcʜιᴇ007, ChrisF, surfasb, 8088, JdeBP Oct 8 '11 at 11:43

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  
Which version of windows? –  OldWolf Oct 7 '11 at 20:21
    
@OldWolf: XP. I prefer not to use any third-party software/ –  David B Oct 7 '11 at 20:24

4 Answers 4

up vote 6 down vote accepted
cd /d C:\Path\To\Source\Folder
for /r %i in (*) do @echo %~ni

If you need the list saved to a file, append >> C:\Path\To\list_file.txt to the end of the for command.

If you end up wanting the extensions, change %~ni to %~nxi

To use in a batch file, change all the % to %%

share|improve this answer
    
If you need path and name and extension, change %~ni to %~pnxi –  Deep Aug 1 at 13:11

If you are willing to load powershell, this command should do it.

get-childitem "d:\acc" -recurse|foreach {$_.Basename}
share|improve this answer

Doing something like the following should get you what you want:

@for /f "delims=" %a in ('Dir /s /b %systemdrive%') do echo %~na

Just pipe the output to a file and use it from there if needed.

share|improve this answer

Don't know if you'd consider it a 3rd party software or not since it's form Microsoft and ships with 7, but powershell will solve most of your problem pretty easily. If you haven't already installed it, it's available for XP on Microsoft's site.

Get-ChildItem -path "C:\Program Files\" -recurse | foreach ($_) {
    write $_.name
}
share|improve this answer

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