gpt4 book ai didi

windows - 为什么我的 Perl 脚本和 Windows 的 SendTo 不能使用超过 20 个文件?

转载 作者:可可西里 更新时间:2023-11-01 10:40:42 26 4
gpt4 key购买 nike

我正在尝试模拟 RapidCRC在 Windows Vista Ultimate 64 位上检查文件名中的 crc32 值的能力。但是,我似乎遇到了某种参数限制。

我写了一个快速的 Perl 脚本,创建了一个批处理文件来调用它,然后在 %APPDATA%\Microsoft\Windows\SendTo 中放置了一个批处理文件的快捷方式

当我选择大约 20 个或更少的文件时,这非常有效,右键单击并“发送到”我的批处理文件脚本。但是,当我选择更多时,什么也没有发生。我怀疑某处存在字符或参数数量限制。

希望我遗漏了一些简单的东西,并且解决方案或解决方法不会太痛苦。

引用资料:

批处理文件(crc32_inline.bat):

crc32_inline.pl %*

Perl 注释:

I'm using (strawberry) perl v5.10.0

I have C:\strawberry\perl\bin in my path, which is where crc32.bat exists.

perl 脚本 (crc32_inline.pl):

#!/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, '>' . $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);
<STDIN>;

最佳答案

我建议只将脚本的快捷方式放在“发送到”目录中,而不是通过批处理文件执行(这受制于 cmd.exe 对命令行长度的限制) .

关于windows - 为什么我的 Perl 脚本和 Windows 的 SendTo 不能使用超过 20 个文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1618899/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com