Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

list.files() all files in directory and subdirectories

Tags:

r

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

like image 365
alki Avatar asked Aug 20 '15 22:08

alki


People also ask

How do I get a list of files in a directory and subdirectories?

The dir command displays a list of files and subdirectories in a directory. With the /S option, it recurses subdirectories and lists their contents as well.

How do I list all files in subdirectories?

By default, ls lists just one directory. If you name one or more directories on the command line, ls will list each one. The -R (uppercase R) option lists all subdirectories, recursively.

How can I get a list of all the subfolders and files present in a directory using PHP?

PHP using scandir() to find folders in a directory The scandir function is an inbuilt function that returns an array of files and directories of a specific directory. It lists the files and directories present inside the path specified by the user.


1 Answers

To list the matching files in all subdirectories, you can use recursive = TRUE in list.files()

list.files(pattern = "_input.txt$", recursive = TRUE) 
like image 88
Rich Scriven Avatar answered Sep 23 '22 05:09

Rich Scriven