r-lib / fs

Provide cross platform file operations based on libuv.
https://fs.r-lib.org/
Other
365 stars 80 forks source link

Improve glob interface for `dir_ls()` #173

Open jimhester opened 5 years ago

jimhester commented 5 years ago

This should work more like the command line

e.g. this should work

fs::dir_ls(glob = "/path/to/file*ext")

now you need to use something like

fs::dir_ls("/path/to", glob = "*file*ext")

Sys.glob("/path/to/file*ext") does work in this way.

ralonso-igenomix commented 5 years ago

Hi,

this would be a great functionality! On the other hand, will it be like Sys.glob that you can put a regular expression in any part oh the path? I mean, in Sys.glob you can do this: Sys.glob("/path/subpath1/*/subpath2/file*ext") but I am not sure if in dir_ls you'll do: fs::dir_ls(glob = "/path/subpath1/*/subpath2/file*ext")

Many thanks

grszkthfr commented 4 years ago

Not sure if this is known/intended, but: fs::dir_ls("/path/to", glob = "*file*ext") is not identical to Sys.glob("/path/to/file*ext"), as the first will find any file containing "file" (e.g. _tmpfile01.ext, _file02.ext, file.ext, ...) while the latter will find only those beginning with "file".

And following this: At the moment fs::dir_ls("/path/to", glob = "file*") is not working. It seems, that the glob argument needs to start with a wildcard to work properly. Not sure if this qualifies as an independent issue...

Best Jonas

ralonso-igenomix commented 2 years ago

Dear,

any update on this?

Best,

Roberto

yzliu01 commented 5 months ago

Hi, How can we use a variable in glob= parameter? It did not work with the below example: group <- "vet_REF_pas" glob = get(paste0("msmc.",group,"_out_non_empty.20bootstrap_chr*.final.txt"))

Error in get(paste0("msmc.", group, "_out_non_empty.20bootstrap_chr*.final.txt")) : 
  object 'msmc.vet_REF_pas_out_non_empty.20bootstrap_chr*.final.txt' not found

Best, Liu

gaborcsardi commented 5 months ago

@yzliu01 You don't need the get(), just the paste0().