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:empest.txt
or
dir *.txt /b /s >> C:empest.txt
and I will get something like
C:estDoc1.txt
C:estsubdirDoc2.txt
C:estsubdirDoc3.txt
If I do
for /r . %%g in (*.txt) do echo %%~nxg >> C:empest.txt
I will get something like
Doc1.txt
Doc2.txt
Doc3.txt
But what I really want is:
Doc1.txt
subdirDoc2.txt
subdirDoc3.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.
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…