use strict; use warnings; use Encode; use MP3::Info; my $dir = ''; binmode STDOUT, ":encoding(UTF-8)"; for my $rawline (`dir /s $ARGV[0]`) { chop($rawline); # remove newline my $line = decode('cp437', $rawline); if ($line =~ /^\d/ && substr($line, 24, 1) eq ' ') { # listing for a file, not a directory my $extix = rindex($line, '.'); my $filename = substr($line, 39); my $filepath = "$dir\\$filename"; my $mp3time = ''; if (lc(substr($line, $extix, 3)) eq '.mp') { # mpeg file my $info = get_mp3info($filepath); if (defined($info)) { print "$filepath: time is $info->{TIME}\n"; } else { print("$filepath: $@\n"); } } } elsif (substr($line, 0, 14) eq ' Directory of ') { $dir = substr($line, 14); $dir =~ s/\\$//; print("$line\n"); } }