fs
fs copied to clipboard
Improve glob interface for `dir_ls()`
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.
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
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. tmpfile_01.ext, file_02.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
Dear,
any update on this?
Best,
Roberto
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
@yzliu01 You don't need the get()
, just the paste0()
.