sanitize_tl.pl 718 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/usr/bin/perl
  2. # Move time codes to end of each line
  3. # and clean some other stuff up if needed
  4. use strict;
  5. use warnings;
  6. if ( ! defined $ARGV[0] ) {
  7. print "Need to pass track list\n";
  8. exit 1;
  9. }
  10. my $file = shift(@ARGV);
  11. foreach my $line ( split("\n", `cat $file`) ) {
  12. chomp $line;
  13. if ( $line =~ m/([0-9]{2}:[0-9]{2})/ ) {
  14. my $time_code = $1;
  15. $line =~ s/ $time_code//g;
  16. $line = $line . " " . $time_code;
  17. }
  18. my $sanitized_line;
  19. open(my $fh, ">>", \$sanitized_line);
  20. my @line_chars = split("",$line);
  21. foreach my $char ( @line_chars ) {
  22. if ( $char !~ m/[a-zA-Z0-9:\s\.-]/ ) {
  23. $char = "";
  24. print $fh "$char";
  25. } else {
  26. print $fh "$char";
  27. }
  28. }
  29. close $fh;
  30. print "$sanitized_line\n";
  31. }