This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Recursive-Glob-Search (once again)

Old posts that have not been replied to for several years.
Locked
K
Kripton
Voice
Posts: 28
Joined: Tue Jan 06, 2004 6:54 am

Recursive-Glob-Search (once again)

Post by Kripton »

Hello!
When searching the "recursive glob"-search here in the forum, I found:
proc recursiveGlob {pattern {dir ./}} {
set files [glob -nocomplain -types f -dir $dir $pattern]
foreach d [glob -nocomplain -types d -dir $dir *] {
set files [concat $files [recursiveGlob $pattern $d]]
}
set files
}
Yes, it DOES look nice, but how do I "start" this one? How do I have to pass the params "pattern" and "dir" to the proces (the "pattern {dir ./}" is too much for me).
And what is the output, when it has finished searching everything? Does it write everything to var "files"?

Please Comment! THX
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Re: Recursive-Glob-Search (once again)

Post by user »

The proc is called with a mask to match against filenames and an optional starting directory. It returns a list of files matching your pattern in the given directory and all its sub directories.

Code: Select all

foreach file [recursiveGlob *.mp3 /my/mp3s] {
	putlog $file
}
Have you ever read "The Manual"?
K
Kripton
Voice
Posts: 28
Joined: Tue Jan 06, 2004 6:54 am

Post by Kripton »

Or may it be, the proc doesn't "like" folders containing spaces?
It managed to search to "Bob Marley and the Wailers" but didn't search this one! Can you fix that?
K
Kripton
Voice
Posts: 28
Joined: Tue Jan 06, 2004 6:54 am

Post by Kripton »

Yes, ok! it works!

Everything was my fault! The user running the EggDrop didn't have the acces to search the MP3-Files! *doh*

Sorry!
Locked