Reputation: 3994
In Ruby, how can I check if a file exists using a wildcard?
Apparently this does not seem to work:
File.exists?("/folderOfFile/Filename*.ext")
Upvotes: 34
Views: 17762
Reputation: 20408
Your wildcard would refer to a set of files, not a single file. You could use Dir::glob for this:
Dir::glob
!Dir.glob('/folderOfFile/Filename*.ext').empty?
Upvotes: 66