Re: mp3 sorting issues :(
Carl D Cravens <[email protected]> Sat, 17 Apr 2004 11:20:47 -0500 (CDT)
| Newsgroups | gmane.org.user-groups.aclug.linux-help |
|---|---|
| Message-ID | <[email protected]> |
On Thu, 15 Apr 2004 [email protected] wrote: > I have a nice little script written to get rid of the bad characters and > convert to underscores, but am having problems getting it to recurse. Is it Perl or shell script? If it's shell script, just use 'find'. Otherwise, a little lesson in recursion is necessary... ===== #!/usr/bin/perl sub descend; $startpoint = '.'; descend( $startpoint ); sub descend { my( $directory, $entry, @entries ); $directory = pop( @_ ); opendir( DIR, $directory ); @entries = readdir( DIR ); closedir( DIR ); foreach $entry ( @entries ) { if ( -d "$directory/$entry" && $entry !~ /^\./ ) { descend( "$directory/$entry" ); # recurse } else { print( "$directory/$entry\n" ); } } } # end of descend ===== (There's probably some Perl module that already does this.) -- Carl D Cravens ([email protected]) I don't have TIME to be charming... -- This is the [email protected] list. To unsubscribe, visit http://www.complete.org/cgi-bin/listargate-aclug.cgi