aboutsummaryrefslogtreecommitdiff
path: root/bin/psycamp
diff options
context:
space:
mode:
authorpsyc://loupsycedyglgamf.onion/~lynX <ircs://psyced.org/youbroketheinternet>2016-08-10 15:28:57 +0000
committerpsyc://loupsycedyglgamf.onion/~lynX <ircs://psyced.org/youbroketheinternet>2016-08-10 15:28:57 +0000
commit94c6660f0ac6c3420c496a0ddb67613cb7e74aff (patch)
tree669631ea0a67d8617acaedda5d918fe50a3fa8e1 /bin/psycamp
parenta727e7f29a0b56121f825beb64074dad90a64752 (diff)
downloadperlpsyc-94c6660f0ac6c3420c496a0ddb67613cb7e74aff.tar.gz
perlpsyc-94c6660f0ac6c3420c496a0ddb67613cb7e74aff.zip
psycamp -F finds duplicate media that wasn't hardlinked
Diffstat (limited to 'bin/psycamp')
-rwxr-xr-xbin/psycamp48
1 files changed, 39 insertions, 9 deletions
diff --git a/bin/psycamp b/bin/psycamp
index 927ed6b..ecdd32e 100755
--- a/bin/psycamp
+++ b/bin/psycamp
@@ -120,7 +120,6 @@ sub HATEINDEX () { "$ENV{HOME}/.media/TRASH-$ENV{HOST}.ix" }
120# a second monitor, it makes sense to run psycamp over there 120# a second monitor, it makes sense to run psycamp over there
121my $screen = 0; 121my $screen = 0;
122 122
123
124### BEGINNING OF REGULAR CODE 123### BEGINNING OF REGULAR CODE
125 124
126 require 5.000; 125 require 5.000;
@@ -626,7 +625,7 @@ X
626 next; 625 next;
627 } 626 }
628 } 627 }
629 if ( /^(J|U|K|E|M|V|X|C|F|L|W|S|R|Y)(\w?)\s*$/ ) { 628 if ( /^(J|U|K|E|M|V|Q|X|C|F|L|W|S|R|Y)(\w?)\s*$/ ) {
630 my $r = $2; 629 my $r = $2;
631 if ($r and $r ne $1) { 630 if ($r and $r ne $1) {
632 &say(BOLD, RED, ">> command $1$r not defined", RESET); 631 &say(BOLD, RED, ">> command $1$r not defined", RESET);
@@ -639,6 +638,7 @@ X
639 $1 eq 'E' ? 'EDITABLE' : 638 $1 eq 'E' ? 'EDITABLE' :
640 $1 eq 'M' ? 'REMASTER' : 639 $1 eq 'M' ? 'REMASTER' :
641 $1 eq 'V' ? 'VOLATILE' : 640 $1 eq 'V' ? 'VOLATILE' :
641 $1 eq 'Q' ? 'COOL' :
642 $1 eq 'X' ? 'EXPORT' : 642 $1 eq 'X' ? 'EXPORT' :
643 $1 eq 'Y' ? 'EASY' : 643 $1 eq 'Y' ? 'EASY' :
644 $1 eq 'C' ? 'CRITICIZE' : 644 $1 eq 'C' ? 'CRITICIZE' :
@@ -718,7 +718,7 @@ X
718# &gin("seek $1 $2"); 718# &gin("seek $1 $2");
719# } 719# }
720 720
721 &scheduledQuit, next if /^q(q|quit)\b/ or /QQ?/; 721 &scheduledQuit, next if /^q(q|quit)\b/;
722 /^(q|quit)\b/ and &save($CS-1), &exit(0); 722 /^(q|quit)\b/ and &save($CS-1), &exit(0);
723 /^(x|exit)\b/ and &exit(0); 723 /^(x|exit)\b/ and &exit(0);
724 /^(w|write)\b/ and &save($CS-1), next; 724 /^(w|write)\b/ and &save($CS-1), next;
@@ -900,6 +900,10 @@ sub sys {
900 900
901sub sorttracks { 901sub sorttracks {
902 my $style = shift; 902 my $style = shift;
903 if ($opt_F) {
904 @dupes = ();
905 $style = 'd';
906 }
903 return (1 .. $NS) unless $style; 907 return (1 .. $NS) unless $style;
904 my @order; 908 my @order;
905 print STDERR "sorting by_$style 1 .. $NS\n" if DEBUG & 8; 909 print STDERR "sorting by_$style 1 .. $NS\n" if DEBUG & 8;
@@ -909,7 +913,8 @@ sub sorttracks {
909Invalid sort option '$style'. Look up '$0 -h' again. 913Invalid sort option '$style'. Look up '$0 -h' again.
910 914
911X 915X
912 return @order; 916 exit if $opt_F;
917 return $style eq 'd' ? @dupes : @order;
913} 918}
914 # r(andom) # bad randomizer algorithm (use -r instead) 919 # r(andom) # bad randomizer algorithm (use -r instead)
915# this actually produces VERY pseudo random results, says randal 920# this actually produces VERY pseudo random results, says randal
@@ -935,8 +940,8 @@ sub by_s {
935 if (DEBUG & 128) { 940 if (DEBUG & 128) {
936 my $B = $size[$b]; my $A = $size[$a]; 941 my $B = $size[$b]; my $A = $size[$a];
937 if ($A == $B) { 942 if ($A == $B) {
938 my ($ad, $ai) = stat $a; 943 my ($ad, $ai) = stat $file[$a];
939 my ($bd, $bi) = stat $b; 944 my ($bd, $bi) = stat $file[$b];
940 # inform of duplicate files in file system 945 # inform of duplicate files in file system
941 # unless they are hard- or softlinked 946 # unless they are hard- or softlinked
942 print MAGENTA, <<X, RESET unless $ai == $bi and $ad == $bd; 947 print MAGENTA, <<X, RESET unless $ai == $bi and $ad == $bd;
@@ -953,19 +958,42 @@ X
953 } 958 }
954} 959}
955sub by_S { 960sub by_S {
956 # one side of this if/else clause gets optimized away at compilation
957 if (DEBUG & 128) { 961 if (DEBUG & 128) {
958 my $B = $size[$b]; my $A = $size[$a]; 962 my $B = $size[$b]; my $A = $size[$a];
959 print MAGENTA, <<X, RESET if $A == $B; 963 if ($A == $B) {
964 my ($ad, $ai) = stat $file[$a];
965 my ($bd, $bi) = stat $file[$b];
966 print MAGENTA, <<X, RESET unless $ai == $bi and $ad == $bd;
960Same file size $B: 967Same file size $B:
961 $file[$a] and 968 $file[$a] and
962 $file[$b] 969 $file[$b]
963X 970X
971 }
964 return $B <=> $A; 972 return $B <=> $A;
965 } else { 973 } else {
966 return $size[$b] <=> $size[$a]; 974 return $size[$b] <=> $size[$a];
967 } 975 }
968} 976}
977sub by_d {
978 my $B = $size[$b]; my $A = $size[$a];
979 if ($A == $B) {
980 my ($ad, $ai) = stat $file[$a];
981 my ($bd, $bi) = stat $file[$b];
982 unless ($ai == $bi and $ad == $bd) {
983 # now we are intentionally doing that job
984 my $rc = system('/usr/bin/cmp', '-s', $file[$a], $file[$b]);
985 unless ($rc) {
986 print <<X;
987$file[$a]
988$file[$b]
989
990X
991 push @dupes, $a, $b;
992 }
993 }
994 }
995 return $B <=> $A;
996}
969 997
970# FIXME: maybe update to use List::Util 'shuffle'; 998# FIXME: maybe update to use List::Util 'shuffle';
971# or maybe this is fine because it does NOT use sort+rand 999# or maybe this is fine because it does NOT use sort+rand
@@ -1049,7 +1077,7 @@ sub wanted {
1049 } 1077 }
1050} 1078}
1051sub progress { 1079sub progress {
1052 return if $opt_q; 1080 return if $opt_q or $opt_F;
1053 my $tx = join('', @_); 1081 my $tx = join('', @_);
1054 my $len = length $tx; 1082 my $len = length $tx;
1055 print "\r", GREEN, $tx, RESET, ' '; 1083 print "\r", GREEN, $tx, RESET, ' ';
@@ -1452,6 +1480,7 @@ the following uppercase commands:
1452 K = send to KEEP 1480 K = send to KEEP
1453 L = send to L8R 1481 L = send to L8R
1454 M = send to REMASTER 1482 M = send to REMASTER
1483 Q = send to COOL
1455 R = send to REPERTOIRE 1484 R = send to REPERTOIRE
1456 S = send to SECONDARY 1485 S = send to SECONDARY
1457 S = send to USE 1486 S = send to USE
@@ -1518,6 +1547,7 @@ __END__
1518 [-d]elete files after playing if the path contains the word '$VOLATILE' 1547 [-d]elete files after playing if the path contains the word '$VOLATILE'
1519 [-D]elete files after playing unless the path contains the word '$KEEP' 1548 [-D]elete files after playing unless the path contains the word '$KEEP'
1520 [-V]oice each file name after playing it 1549 [-V]oice each file name after playing it
1550 [-F]ind duplicates of files which aren't hardlinked, like fdupes
1521 1551
1522 Without arguments, psycamp resumes from last run's playlist. 1552 Without arguments, psycamp resumes from last run's playlist.
1523 1553