Try this:
Dir.glob("#{folder}/**/*.pdf")
which is the same as
Dir["#{folder}/**/*.pdf"]
Where the folder variable is the path to the root folder you want to search through.
Try this:
Dir.glob("#{folder}/**/*.pdf")
which is the same as
Dir["#{folder}/**/*.pdf"]
Where the folder variable is the path to the root folder you want to search through.