Re: [linux-audio-user] ardour and mp3?

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: A list for linux audio users <linux-audio-user@...>
Date: Saturday, February 3, 2007 - 10:50 pm

On Sat, Feb 03, 2007 at 05:33:42PM -0500, Paul Davis wrote:

doesn't everyone have a perl script that fixes spaces in files?

... they should:

#!/usr/bin/perl -w

### fix_fn_keep_ext.pl ###

if( ! defined($ARGV[0]) ){
die "$0 [files...]\n";
}

foreach ( @ARGV ){
if( -f $_ ){
rename( $_ , fix_fn( $_ ) );
} else {
die "$file is not a file(or doesn\'t exist)";
}
}

#########################################
sub fix_fn { # string
my($fn);
my(@fn_arr);
if(defined($_[0])){
$fn = $_[0];}
else{ die"fix_fn() needs 1 arg : $!";}

@fn_arr = split_on_suffix( $fn );
$fn = replace_bad_chars( $fn_arr[0] );

$fn = $fn . '.' . $fn_arr[1];

return( $fn);
}

sub replace_bad_chars { # string
my($fn);
my(@fn_arr);
if(defined($_[0])){
$fn = $_[0];}
else{ die"replace_bad_chars() needs 1 arg : $!";}

@fn_arr = split( /\W+/ , $fn);
$fn = join( '_' , @fn_arr ) ;
return( $fn );
}

sub split_on_suffix { # string
my($fn);
my($suffix);
my(@fn_arr);
if(defined($_[0])){
$fn = $_[0];}
else{ die"strip_suffix() needs 1 arg : $!";}

@fn_arr = split( /\./ , $fn );

$suffix = pop( @fn_arr );

$fn = join( '.' , @fn_arr );

@fn_arr = ( $fn , $suffix );

return( @fn_arr );
}

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[linux-audio-user] ardour and mp3?, Matt Price, (Sat Feb 3, 9:39 pm)
Re: [linux-audio-user] ardour and mp3?, rob, (Sun Feb 4, 11:30 am)
Re: [linux-audio-user] ardour and mp3?, Brian Dunn, (Sat Feb 3, 10:17 pm)
Re: [linux-audio-user] ardour and mp3?, Adam Sampson, (Sun Feb 4, 2:56 pm)
Re: [linux-audio-user] ardour and mp3?, Brian Dunn, (Tue Feb 6, 8:05 pm)
Re: [linux-audio-user] ardour and mp3?, Ken Restivo, (Sat Feb 3, 10:16 pm)
Re: [linux-audio-user] ardour and mp3?, Paul Davis, (Sat Feb 3, 10:33 pm)
Re: [linux-audio-user] ardour and mp3?, Ken Restivo, (Sun Feb 4, 4:06 am)
Re: [linux-audio-user] ardour and mp3?, paul wisehart, (Sat Feb 3, 10:50 pm)
Re: [linux-audio-user] ardour and mp3?, Arnold Krille, (Mon Feb 5, 8:55 pm)
Re: [linux-audio-user] ardour and mp3?, Paul Davis, (Sat Feb 3, 9:58 pm)
Re: [linux-audio-user] ardour and mp3?, Matt Price, (Tue Feb 6, 4:27 pm)
Re: [linux-audio-user] ardour and mp3?, Paul Davis, (Tue Feb 6, 6:34 pm)