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.
By default, ls lists just one directory. If you name one or more directories on the command line, ls will list each one. The -R (uppercase R) option lists all subdirectories, recursively.
Use the ls command to display the contents of a directory. The ls command writes to standard output the contents of each specified Directory or the name of each specified File, along with any other information you ask for with the flags.
You can use the DIR command by itself (just type “dir” at the Command Prompt) to list the files and folders in the current directory.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With