#!/usr/bin/perl my $target = "/home/zsolti/Temp"; my @exclude = ( #'2023_02_21_Szentendre_Pilis_EK_oldal' 'webftp' ,'x' ); my (@audioFiles, %playList); my $numOfRandFiles = 10; &fileExplore($target); #print join("\n", @audioFiles), "\n"; &uploadPlaylist; print "-" x 80, "\n", "SELECTED FILES:\n", "-" x 80, "\n"; foreach $key (sort {$playList{$a} <=> $playList{$b}} (keys(%playList))) { print "$playList{$key}: $key\n"; } sub fileExplore { my $dir = shift; my $hit = 0; local *DIR; opendir DIR, $dir or die "opendir $dir: $!"; my $found = 0; while ($_ = readdir DIR) { next if /^\.{1,2}$/; $FSNode = $_; my $FSObj = "$dir/$FSNode"; foreach my $exc (@exclude) {$hit = 1 if $FSObj =~ m/\/$exc\//g} next if $hit; if (-f $FSObj) { (my $fExt = $FSObj) =~ s/.*\.(.*$)/$1/i; push(@audioFiles, $FSObj) if lc($fExt) eq 'mp3'; } fileExplore($FSObj) if -d $FSObj; } closedir DIR; } sub uploadPlaylist { for (my $i = 1; $i <= $numOfRandFiles; $i++) { $playList{$audioFiles[int rand@audioFiles]} = $i; } }