Search code examples
windowsrecursioncmdpathdir

Recursive Cmd Dir with Full Path for each line


I'd like to make a recursive dir command on Windows which allows me to have for each line the full path of each file.

Here is the example I'd like to improve with full path of each file instead of just the filename :
dir /S | findstr /R "^.*.xlsm$"

Current output :

01/01/2012  00:01  1 023 456 fileName.xlsm
02/01/2015  01:02  2 345 678 fileName2.xlsm

Expected output :

01/01/2012  00:01  1 023 456 C:\Path\To\File\fileName.xlsm
02/01/2015  01:02  2 345 678 C:\Path\To\Other\File\fileName2.xlsm

Solution

  • Thanks to lunacodes I could improve my answer with its path of solution.

    Here is the input I produced which helped my case :
    for /f "tokens=*" %a in ('dir /s /b') do echo %~za;%~ta;%~fa | findstr /R ".xlsm"