Complete.Org: Mailing Lists: Archives: linux-help: April 2004:
[linux-help] Re: mp3 sorting issues :(
Home

[linux-help] Re: mp3 sorting issues :(

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: linux-help@xxxxxxxxx
Subject: [linux-help] Re: mp3 sorting issues :(
From: Carl D Cravens <raven@xxxxxxxxxxx>
Date: Sat, 17 Apr 2004 11:20:47 -0500 (CDT)
Reply-to: linux-help@xxxxxxxxx

On Thu, 15 Apr 2004 dustin@xxxxxxxx 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 (raven@xxxxxxxxxxx)
I don't have TIME to be charming...
-- This is the linux-help@xxxxxxxxx list.  To unsubscribe,
visit http://www.complete.org/cgi-bin/listargate-aclug.cgi


[Prev in Thread] Current Thread [Next in Thread]