问题
I'm trying to list all the files in a directories including subdirectories that end with _input.txt
.
- folder 1
- a_input.txt
- folder 2
- b_input.txt
If folder 1 were my working directory, I would like list.files(pattern = "\\_input.txt$")
to be able to detect both a_input.txt
and b_input.txt
回答1:
To list the matching files in all subdirectories, you can use recursive = TRUE
in list.files()
list.files(pattern = "_input.txt$", recursive = TRUE)
来源:https://stackoverflow.com/questions/32129687/list-files-all-files-in-directory-and-subdirectories