Recursively list all files with .txt extension from the current folder printing the file name and only the relative folder path
In a bat file, I am trying to recursively list all files with .txt extension from the current folder printing the file name and only the relative folder path.
I have tried many solutions, the closest one to what I want is this:
@REM :treeProcess
@REM FOR %%f in (*.jmx) do echo %%f
@REM FOR /D %%d in (*) do (
@REM cd %%d
@REM call :treeProcess
@REM cd ..
@REM )
But this prints the abosolute path and I need the relative path.
Example structure of what I need:
Current directory is C:\test
File a.txt
Folder 1
File a1.txt
Folder 1.1
File a2.txt
Folder 1.2
Expected result:
a.txt
Folder 1\a1.txt
Folder 1\Folder 1.1\File a2.txt
CodePudding user response:
Try this in a bat file that you will execute from the C:\test\ folder.
SET "StartPath=