How to search a folder and all of its subfolders for files of a certain type

前端 未结 5 718
無奈伤痛
無奈伤痛 2020-11-29 22:19

I am trying to search for all files of a given type in a given folder and copy them to a new folder.

I need to specify a root folder and search through that folder a

5条回答
  •  一个人的身影
    2020-11-29 22:31

    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.

提交回复
热议问题