Click here to Skip to main content
14,695,235 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
for eg i have a system how to find all the fixed drives first then iterate them one by one recursively i.e search all folders and subfolders for specific extensions like .mp3,.mp4,.wav etc
with below command i can search in onl one drive that too i am hard coding plus i can only search for only one extension with below method

What I have tried:

dir /s/b "D:\*.pdf"
Updated 3-Aug-20 9:55am

Use dir with several files/extensions:
dir "C:\Folder-A\File-1.txt" "D:\Folder-B\File-2.log"  ...

Also use for loop to gets all the logical drivers on your system, try:
rem ::  In command Line :
for /F %i in ('wmic logicaldisk get deviceID^|find ":"')do echo\ dir /s /b %i\*.mp3 %i\*.mp4 %i\*.wav
rem ::  In .bat/.cmd file :
for /F %%i in ('wmic logicaldisk get deviceID^|find ":"')do echo\ dir /s /b %%i\*.mp3 %%i\*.mp4 %%i\*.wav

After testing the output, remove: echo \
em :: To omit "file not found", if there are no files on the drive
)do... 2>nul dir /s %i\ *.mp3 *.mp4 *.wav

If necessary, add the full path (recommendable):

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900