Your shortenfilename could use a hash, something like:
Using MS's idea of 6 and ~X, you could then:my %oldfiles; foreach $file (@FileArray){ if (length($file)>13){ $shortenedname = substr($file, 0, 8); $shortenedname = $shortenedname.".mp3"; } else {$shortenedname = $file;} if ( $oldfiles{$shortenedname}++ ) { # short name already exist, try again ...
which it to also point out that shortenfilenames seems to be returning the same array it gets, unchanged. Change $file isn't going to modify the array members.if ( $oldfiles{$shortenedname}++ ) { my $base = substr($file, 0, 6); my $test_shortenedname = 'not found'; for my $i ( 1 .. 9, a .. z ) { $test_shortenedname = $base . '~' . $i; unless $oldfiles{$test_shortenedname}; } next if ($test_shortenedname eq 'not found'); # rather than die, just skip the bad/unshortenable name $shortenedname = $test_shortenedname } push @short_files, $shortenedname; } return @short_files;
removemp, you probably want:
That is, you want only files that end in '.mp3', notif ($file =~ /\.mp3$/i ){ push(@mp3files, $file); }
I think you'll be clobbering your log file everytime, as you're opening it in overwrite mode ('>eXpanium.log') each time. There's something odd about redefining the log file name in one sub and opening it in another. Log file names, unless you're numbering them (logfile1.log, logfile2.log) are probably better global. You pass @newfiles all the time, except for rename, probably should be consistent on that or just 'in-line' rename in main.
Just some suggestions, YM will always V ...
a
In reply to Re: eXpanium file converter
by a
in thread eXpanium file converter
by C-Keen
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |