如何从目录中获取文件名和扩展名

时间:2023-01-16 23:59:51

I have a folder and I am trying to get all file names and file extension. How could I do this? I couldn't find any helpful example to do this, I am already tired looking for it if anyone could help me with that it will be appreciated

我有一个文件夹,我试图获取所有文件名和文件扩展名。我怎么能这样做?我没有找到任何有用的例子来做这件事,我已经厌倦了寻找它,如果有人可以帮助我,将不胜感激

Thanks

2 个解决方案

#1


3  

Dir.glob("*")
# => ["test.rb", "a.txt", ..... ]
# or find all files recursively
Dir.glob("./**/*")

#2


0  

you can use php function scandir('path')

你可以使用php函数scandir('path')

#1


3  

Dir.glob("*")
# => ["test.rb", "a.txt", ..... ]
# or find all files recursively
Dir.glob("./**/*")

#2


0  

you can use php function scandir('path')

你可以使用php函数scandir('path')