From 914ffba685b594c11bbfb8559a44f54042e40d83 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 14 May 2018 20:38:13 +0200 Subject: get pl param printing being nice --- get.pl | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'get.pl') diff --git a/get.pl b/get.pl index 0ef39db..4b94c22 100755 --- a/get.pl +++ b/get.pl @@ -2,6 +2,19 @@ $SIG{TERM} = $SIG{INT} = sub { exit 1 }; +sub sanitize ($) { + my $s = lc shift; + $s =~ s/\.[^.]+$//g; + $s =~ s/\W//g; + $s =~ s/\s+/_/g; + if (length($s) == 0) { + print "fn is empty"; + exit(1); + } + $s =~ s/_+/_/g; + return $s; +} + chdir('datasets'); my $fn, $new_fn; @@ -22,19 +35,10 @@ foreach my $s (@ARGV){ } } if ($fn) { - $new_fn = lc $fn; - $new_fn =~ s/\.flac$//g; - $new_fn =~ s/\s+/_/g; - $new_fn =~ s/\W//g; - if (length($new_fn) == 0) { - $new_fn = lc $s; - $new_fn =~ s/\s+/_/g; - $new_fn =~ s/\W//g; - } - $new_fn =~ s/_+/_/g; + $new_fn = sanitize($fn) $new_fn .= '.flac'; system('mv', $fn, $new_fn); - print"got fn, $fn => $new_fn\n"; + print "got fn, $fn => $new_fn\n"; system('/usr/bin/perl', 'dataset.pl', $new_fn); } } @@ -44,8 +48,9 @@ foreach my $s (@ARGV){ system('/usr/bin/wget', 'https://neural:spawn5@asdf.us/neural/' . $s); system('/usr/bin/perl', 'dataset.pl', $s); } + my $tag = sanitize($fn); open(my $fd, ">>../run_slap.sh"); - print $fd "standard $fn"; + print $fd "standard $tag\n"; close $fn; $fn = undef; -- cgit v1.2.3-70-g09d2