--AJ3oM32U01nchLSz
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

* STEPHEN BECKER I V (Becker004 / gmail.com) wrote:
> I am writing a program to go in all the folders, then in to there
> folders.... 

Hi Stephen,

It looks like all you do is print out the directory name.  This might be
a bit closer to what you're looking for:

def recurse(path, max_depth = 5)
  Dir::entries(path).select do |file|
    file !~ /^\./ && test(?d, File::join(path, file)) 
  end.each do |dir| 
    puts File::join(path, dir)
    recurse(File::join(path, dir), max_depth - 1) if max_depth > 0
  end
end

Hope this helps...

> def dirsearch (coming_in) #declare coming_in is the directory to be searched
> print "\n\n\n",coming_in," line 2 \n\n\n" #testing
> Dir.chdir(coming_in) #change to the directory
> mainloc = Dir.getwd #new base
> file = Array.new 
> 
> print "\n\n\n",mainloc," line 7 \n\n\n" #testing
> 
> loc = Dir.open(mainloc) #open the folder
> loc.each  {|x| file.push(x) } #get the folders and files
> 
> dir = Array.new 
> count = file.size #amounts
> 
> if count==0 then break end#check if there are any files
> print "-----------list------------",count,"--"
> while count>0
> if(!(file[count-1].include? ?.)) #for windows assume that file has an
> extension and no folders have a .
> reform = mainloc +'/'+  file[count-1] # create list of folders
> print reform
> dir.push(reform)
> end
> count-=1
> end
> print "\n"
> if !(dir.size==0) then #check if any folders to go in to
> many = dir.size-1;
> while many>0 
> print dir[many],"loop at 28th\n"
> if(!(dir[many].nil?))then #having a problem with nil folders? any help?
> dirsearch(dir[many])#call function with new directory
> end
> many-=1
> end
> end
> end
> 
> dirsearch("c:") # light the candle
> 
> 
> i am using SciTE in windows XP. It just seems to be cutting out after
> about 5 runs of the function. Am i writing over the same variables?
> Becker
> 

-- 
Paul Duncan <pabs / pablotron.org>        pabs in #ruby-lang (OPN IRC)
http://www.pablotron.org/               OpenPGP Key ID: 0x82C29562

--AJ3oM32U01nchLSz
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)

iD8DBQFBVJh3zdlT34LClWIRAppfAJ99TEp4afxH5gsD14dm+JLV+tFWbgCgkTtO
O4UKunW68kPwl6a/QQDvbGwy
-----END PGP SIGNATURE-----

--AJ3oM32U01nchLSz--