I have thousands of different files (having the same extension .img
) in a folder called data
. If I use this :
dir<- list.files ("C:\\Users\\data", "*.img", full.names = TRUE)
It will list all files I have in the folder data
.
What I need is just to list the files named as:
File_yyyymmdd_data.img (in which yyyymmdd varies for 10 years)
Any idea or hint is appreciated!
try this
files.new = list.files(directory.path, recursive = TRUE, pattern=".img")
Where, "directory.path" is the path to the directory containing files you need to read
edited
to be more appropriate
files.new = list.files(directory.path, recursive = TRUE, pattern="File_[0-9]{8}_data[.]img$")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With