
Robert S. answered 11/22/19
R Developer and Analyst
I'm not sure of the complexity of how you want to list all the files (i.e. do you want the output in a list type, or a vector of file names?) or how you will import each file, but the simplest method would be to use the `pattern` input within `list.files()` to obtain a vector of file names and then subsetting the vector to contain only the .dbf extension.
To demonstrate what I'm thinking of, see below:
```
dbfs <- list.files('C:\\Scratch', pattern = '\\.dbf')
dbf_only <- subset(dbfs, substr(dbfs, nchar(dbfs) - 3, nchar(dbfs)) == '.dbf')
dbf_only # Should be a vector of .dbf file names only.
# Alternate approach with the tidyverse:
library(tidyverse)
list.files('C:\\Scratch', pattern = '\\.dbf') %>%
subset(., substr(., nchar(.) - 3, nchar(.)) == '.dbf')
```
Hopefully, this answers your question!