Find.find("/Users/alamb/_Current-Work/fiches") do |path|
if(path =~ /100_/)
...
In order to get all the files of the directory which have "100_" in the name.
Two questions:
1) Is there a way to use the find method to directly achieve this?
2) I tried a Regexp with /^100_/ to say "files starting with '100_' " but it doensn't seem to work.
Any idea?
Thanks
···
--
Alexander Lamb
Service d'Informatique Médicale
Hôpitaux Universitaires de Genève Alexander.J.Lamb@sim.hcuge.ch
+41 22 372 88 62
+41 79 420 79 73
Find.find("/Users/alamb/_Current-Work/fiches") do |path|
if(path =~ /100_/)
...
In order to get all the files of the directory which have "100_" in the name.
Two questions:
1) Is there a way to use the find method to directly achieve this?
2) I tried a Regexp with /^100_/ to say "files starting with '100_' " but it doensn't seem to work.
I don't usually use Find... Dir is fairly powerful.
Dir["100*"] # all 100-type files in current dir
Dir["**/100*"] # all in this tree (correct syntax??)
rio("/Users/alamb/_Current-Work/fiches").files(/^100_/) do |path|
...
end
To include files in subdirectories that start with '100_' use:
rio("/Users/alamb/_Current-Work/fiches").all.files(/^100_/) do |path|
...
end
Hal Fulton wrote:
···
Alexander Lamb wrote:
> Hello,
>
> I am doing something like this:
>
> Find.find("/Users/alamb/_Current-Work/fiches") do |path|
> if(path =~ /100_/)
> ...
>
> In order to get all the files of the directory which have "100_" in the
> name.
>
> Two questions:
>
> 1) Is there a way to use the find method to directly achieve this?
> 2) I tried a Regexp with /^100_/ to say "files starting with '100_' "
> but it doensn't seem to work.
I don't usually use Find... Dir is fairly powerful.
Dir["100*"] # all 100-type files in current dir
Dir["**/100*"] # all in this tree (correct syntax??)