R – Find all file names that match a pattern

rregex

I am trying to find a way to list all file names in a folder that matches this pattern :

20131106XXXXX.pdf 

The prefix is the date, and the content and length of XXXX vary across files, and I only care about pdf files.

Anyone could advise a way to do this?

Best Solution

Try this

list.files(path="./yourdir",pattern="[[:digit:]]{8}.*\\.pdf")