dimanche 29 mars 2015

Search for a folder only for a certain level (3 sub directories only)

Currently I am searching for a '.svn' folder inside a path using the below code :



require 'find'
svn_folders = []
@folder_path = 'C:\my_repositories\'
Find.find(@folder_path) do |path|
svn_folders << path if path =~ /.*\.svn$/
end


The above code will search all the folders inside @folder_path and lists me with the svn_folders path.


But, the big problem is that these folders are a big (50GB +) so searching for the '.svn' folder takes a lot of time to search.


Question : Is it possible to search only for certain level of sub folders, 3 sub folders in my case?


Example : If my folder path is C:\my_repositories


I would like to search 3 layers (sub folders) down i.e, till C:\my_repositories\project_name\repository_name\repository


and would not like to search beneath the folder named repository.


Any suggestions would be really helpful. Thank you very much in advance.


Aucun commentaire:

Enregistrer un commentaire