Click here to Skip to main content
15,879,535 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"
Posted
Updated 3-Aug-20 8: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):
%__APPDIR__%wbem\wmic.exe
 
Share this answer
 
v4

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