#!/usr/bin/perl
opendir(FILES, ".") || die ("Unable to open directory");
@in_files = readdir(FILES);
closedir(FILES);
foreach $filename (@in_files)
{
if ($filename =~ /([a-z0-9\_]+)(\.[gifbmpjpgn]{3}) *$/i)
{
$out_file = $1 . "_bw" . $2;
system("convert ${filename} -set colorspace Gray -separate -average ${out_file}");
}
}
exit;
#!/usr/local/bin/python
import os, re, string
filelist = os.listdir(".")
for file in filelist:
if ".jpg" in file or ".bmp" in file or ".gif" in file or ".png" in file:
outfile = "bw_" + file
command = "convert " + file + " -set colorspace Gray -separate -average " + outfile
os.system(command)
#print command
exit
#!/usr/local/bin/ruby
filelist = Dir.glob("*.*")
filelist.each do
|file|
if file =~ /([a-z0-9\_]+)(\.[gifbmpjpgn]{3}) *$/i
out_file = $1 + "_bw" + $2
system("convert " + file + " -set colorspace Gray -separate -average " + out_file)
end
end
exit
© 2008 Jules BermanAs with all of my scripts, lists, web sites, and blog entries, the following disclaimer applies. This material is provided by its creator, Jules J. Berman, "as is", without warranty of any kind, expressed or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. in no event shall the author or copyright holder be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the material or the use or other dealings.