9755afabdbcf83bdf7cf50d19719902b249519f1
commit 9755afabdbcf83bdf7cf50d19719902b249519f1
Author: spesk1 <spesk@pm.me>
Date: Mon Jul 29 14:49:20 2019 -0400

Adding filename strip

diff --git a/strip_filename.pl b/strip_filename.pl
new file mode 100755
index 0000000..d609b3d
--- /dev/null
+++ b/strip_filename.pl
@@ -0,0 +1,47 @@
+#!/usr/bin/env perl
+
+# Stupid script to strip trash formatted filenames
+
+use strict;
+use warnings;
+
+my @inputs = @ARGV;
+
+sub strip_filename($) {
+
+ my $filename = shift;
+ my @chars = split("",$filename);
+ my $new_filename;
+ open(my $fh, ">>", \$new_filename) or die "Couldn't open new_filename var\n";
+ foreach my $char ( @chars ) {
+ if ( $char =~ m/\s/ ) {
+ next;
+ } elsif ( $char =~ m/\(|\)|\\|\'|\$|\!|,/ ) {
+ next;
+ } else {
+ print $fh $char;
+ }
+ }
+ close $fh;
+ return $new_filename;
+}
+
+sub rename_file($$) {
+
+ my ( $old_filename, $new_filename ) = @_;
+ my $cmd = "mv '$old_filename' $new_filename";
+ print "$cmd\n";
+ system("$cmd");
+
+}
+
+foreach my $input ( @inputs ) {
+ if ( ! -f $input ) {
+ print "File at path $input doesn't look like a file\n";
+ exit 1;
+ }
+ print "$input\n";
+ my $new_filename = strip_filename($input);
+ print "$new_filename\n";
+ rename_file($input,$new_filename);
+}