Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy can't I use more than 20 files with my Perl script and Windows's SendTo?
    text
    copied!<p>I'm trying to emulate <a href="http://rapidcrc.sourceforge.net/" rel="nofollow noreferrer">RapidCRC</a>'s ability to check crc32 values within filenames on Windows Vista Ultimate 64-bit. However, I seem to be running into some kind of argument limitation.</p> <p>I wrote a quick Perl script, created a batch file to call it, then placed a shortcut to the batch file in <code>%APPDATA%\Microsoft\Windows\SendTo</code></p> <p>This works great when I select about 20 files or less, right-click and "send to" my batch file script. However, nothing happens at all when I select more than that. I suspect there's a character or number of arguments limit somewhere.</p> <p>Hopefully I'm missing something simple and that the solution or a workaround isn't too painful.</p> <p><strong>References:</strong></p> <p>batch file (crc32_inline.bat):</p> <pre><code>crc32_inline.pl %* </code></pre> <p>Perl notes:</p> <blockquote> <p>I'm using (strawberry) perl v5.10.0</p> <p>I have C:\strawberry\perl\bin in my path, which is where crc32.bat exists.</p> </blockquote> <p>perl script (crc32_inline.pl):</p> <pre><code>#!/usr/bin/env perl use strict; use warnings; use Cwd; use English qw( -no_match_vars ); use File::Basename; $OUTPUT_AUTOFLUSH = 1; my $crc32_cmd = 'crc32.bat'; my $failure_report_basename = 'crc32_failures.txt'; my %failures = (); print "\n"; foreach my $arg (@ARGV) { # if the file has a crc, check to see if it matches the calculated # crc. if (-f $arg and $arg =~ /\[([0-9a-f]{8})\]/i) { my $crc = uc $1; my $basename = basename($arg); print "checking ${basename}... "; my $calculated_crc = uc `${crc32_cmd} "${arg}"`; chomp($calculated_crc); if ($crc eq $calculated_crc) { print "passed.\n"; } else { print "FAILED (calculated ${calculated_crc})\n"; my $dirname = dirname($arg); $failures{$dirname}{$basename} = $calculated_crc; } } } print "\nReport Summary:\n"; if (scalar keys %failures == 0) { print " All files OK\n"; } else { print sprintf(" %d / %d files failed crc32 validation.\n" . " See %s for details.\n", scalar keys %failures, scalar @ARGV, $failure_report_basename); my $failure_report_fullname = $failure_report_basename; if (defined -f $ARGV[0]) { $failure_report_fullname = dirname($ARGV[0]) . '/' . $failure_report_basename; } $OUTPUT_AUTOFLUSH = 0; open my $fh, '&gt;' . $failure_report_fullname or die $!; foreach my $dirname (sort keys %failures) { print {$fh} $dirname . "\n"; foreach my $basename (sort keys %{$failures{$dirname}}) { print {$fh} sprintf(" crc32(%s) basename(%s)\n", $failures{$dirname}{$basename}, $basename); } } close $fh; $OUTPUT_AUTOFLUSH = 1; } print sprintf("\n%s done! (%d seconds elapsed)\n" . "Press enter to exit.\n", basename($0), time() - $BASETIME); &lt;STDIN&gt;; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload