1

Looking through Google and super user stack exchange showed me how to search a folder and it's subfolder for hidden files

dir /A:H /S testHiddenFile*.txt

or hidden folders:

dir /A:HD /S testFolder

But how do I search through all sub folders (hidden or non-hidden) for all files with a particular extension. For example I want to find the location of *.log files under C:\Users\SomeUser\ but these files could be under hidden folders.

0

2 Answers 2

2

Use attrib /s /d *.* command. See more: https://ss64.com/nt/attrib.html

3

Taken and adapted from this answer, it will recurse through all folders whether or not they are Hidden and find files whether or they are hidden:

REM Recursive scan through all folders with or without Hidden attribute for any files
for /f "tokens=* delims=" %i in ('dir /b/s/a-d *') do echo "%i"

Adapted for your taste for finding all *.log files:

REM Recursive scan through all folders with or without Hidden attribute for .log files
for /f "tokens=* delims=" %i in ('dir /b/s/a-d *.log') do echo "%i"

If you want to save their directories to file myFiles.txt:

for /f "tokens=* delims=" %i in ('dir /b/s/a-d *.log') do echo "%i">>myFiles.txt

If you want to open all your files one at time:

for /f "tokens=* delims=" %%i in ('dir /b/s/a-d *.log') do (
    pause
    echo.
    echo Opening file "%%i"...
    notepad.exe "%%i"
)
1
  • Thanks. Upvoted cause this worked as well, though it's longer than the answer in @Biswa's comment (attrib /s/d *.log).
    – Ash
    Commented Aug 31, 2017 at 4:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .