Concerning Windows batch files: Is there a way to list all the files (or all of a specific type) in a certain directory and its subdirectories, including the paths relative to the current (or the search) directory in the list?
For example, if I want all the .txt files in the current directory and subdirectories with their full paths, I can do
for /r . %%g in (*.txt) do echo %%g >> C:\temp\test.txt
or
dir *.txt /b /s >> C:\temp\test.txt
and I will get something like
C:\test\Doc1.txt
C:\test\subdir\Doc2.txt
C:\test\subdir\Doc3.txt
If I do
for /r . %%g in (*.txt) do echo %%~nxg >> C:\temp\test.txt
I will get something like
Doc1.txt
Doc2.txt
Doc3.txt
But what I really want is:
Doc1.txt
subdir\Doc2.txt
subdir\Doc3.txt
Is it possible?
If my post is too confusing: I basically want List files recursively in Linux CLI with path relative to the current directory, but just for Windows.
You could simply get the character length of the current directory, and remove them from your absolute list