9

I Have a directory containing many subdirectories. Within these subdirectories are loads of .asf, .jpg, & .txt files. I would like to list all *.asf files within the directory and subdirectory but without the pathname.

So basically I want to do the dir /s command but not display the full pathname. Is there anyway to do this.

0m3r
  • 12,286
  • 15
  • 35
  • 71
Nicknz125
  • 91
  • 1
  • 1
  • 2

4 Answers4

12

Very late but may be useful to someone. I guess he is asking for this one line command

forfiles /m *.asf /s >d:\Hitendra.Txt

here as you all know after this (>) I'm saving result in D drive of my computer with a file name Hitendra.Txt

0m3r
  • 12,286
  • 15
  • 35
  • 71
Hitendra
  • 129
  • 1
  • 2
6

Check:

FORFILES /S /C "CMD /C ECHO @relpath"
LS_ᴅᴇᴠ
  • 10,823
  • 1
  • 23
  • 46
5

try this on the cmd shell prompt:

for /r %a in (*.asf) do @echo %~tza %~nxa

only the name:

for /r %a in (*.asf) do @echo %~nxa
Endoro
  • 37,015
  • 8
  • 50
  • 63
4

You can try

dir /s | findstr .asf

Edit: I think this would help. This is my test.bat

@echo off
for /f "usebackq TOKENS=*" %%i in (`dir /s /b *.txt`) do echo %%~nxi
pause

/f usebackq says that whatever inside backquotes are executed as dos command

TOKENS=* parses file names with spaces also.

echo %%~nxi - n lists out only the file names and x lists out only the extension. Combining both displays file name and extension.

Edit: usebackq is not necessary instead single quote can be used.

Sakthi Kumar
  • 3,047
  • 15
  • 28
  • Thanks for your reply. However this still lists the complete path of each file, I would like to just extract the 'filename.asf'. – Nicknz125 Aug 23 '13 at 09:12
  • `usebackq` means the quoting scheme has changed, **not** a command follows. See `for /?` for help. You don't need `usebackq` here. – Endoro Aug 23 '13 at 12:44