0
私は、Rを使ってテキストファイルにいくつかのperlスクリプトを書き込もうとしている。私は特定の文字をエスケープする方法を理解できませんか?テキストファイルに書き込むが、特殊文字をエスケープする
バックスラッシュ(一重と二重)、大括弧、 "\\ Q ... \\ E"などを使用しましたが、それでも機能させることはできません。
ご協力いただければ幸いです。前もって感謝します!
taskFilename = "example.txt"
cat("
#!/usr/bin/perl
use strict;
use warnings;
use File::Find;
use File::Temp qw(tempfile);
my @imagedir_roots = ("/Users/Ross/Desktop/images");
my $parallel = 8;
my $exiftool_command = 'exiftool -all= -tagsfromfile @ -all:all --gps:all --xmp:geotag -unsafe -icc_profile -overwrite_original';
# Create the (temporary) [email protected] files
my @atfiles;
my @atfilenames;
for (my $i = 0; $i < $parallel; ++$i) {
my ($fh, $filename) = tempfile(UNLINK => 1);
push @atfiles, $fh;
push @atfilenames, $filename;
}
# Gather all JPG image files and distribute them over the [email protected] files
my $nr = 0;
find(sub { print { $atfiles[$nr++ % $parallel] } "$File::Find::name\n" if (-f && /\.(?:jpg|jpeg)/i); }, @imagedir_roots);
# Process all images in parallel
printf("Processing %d JPG files...\n", $nr);
for (my $i = 0; $i < $parallel; ++$i) {
close($atfiles[$i]);
my $pid = fork();
if (!$pid) {
# Run exiftool in the background
system qq{$exiftool_command [email protected] \"$atfilenames[$i]\"};
last;
}
}
# Wait for processes to finish
while (wait() != -1) {}
", fill = TRUE, file = taskFilename
)
を\\する必要があります!完璧に動作します。 – Ross