linux下修改并当前目录下图像文件并删除
linux下修改并当前目录下图像文件并删除
linux下修改并当前目录下图像文件并删除
Linux下;
需要安装 Image Magick。
仅供参考,注意安全。
使用时注意修改。
01
#!/usr/bin/perl
02
# change image size
03
use strict;
04
use warnings;
05
06
# get files to be modified
07
print "Image Format(jpg or JPG or else): ";
08
chomp(my $format = <STDIN>);
09
my @files = glob "*.$format";
10
11
my $filename;
12
for (@files) {
13
# file name
14
$filename = /(\d+\.jpg)/i ? $1 : "1_$_";
15
16
# change size
17
system "convert -sample 25%x25% '$_' $filename";
18
19
print "converting $_ ...\n";
20
}
21
print "Convert finished!\n\nRemove files:\n@files...??????????????????\n\nYes or No?: ";
22
chomp(my $choice = <STDIN>);
23
24
if ($choice =~ /^y/i) {
25
foreach (@files) {
26
system "rm '$_' -v";
27
}
28
} else {
29
print "OK, I won't delete them. Bye!\n";
30
exit;
31
}
32
33
print "Done!\n";
评论暂时关闭