#! /usr/local/bin/perl -w

	# get all ps files and change them into gif files

@ps_files = </users/asc/level2/data/mag/orig_data/acesummary_*.ps>;

foreach (@ps_files){
	$ps_fn = $_;
	$gif_fn = $_;
	$gif_fn =~ s/.*acesummary(_\d+-\d+).*ps/MAGSUMMARY${1}.gif/;
	# print $gif_fn, "\n";
	### change postscript into ppm files
	print "$_  ", `pstopnm $_`;
	### change $_ to the output filename of "pstopnm"
	s/.*(acesummary_\d+-\d+.*)\.ps/${1}001\.ppm/;
	print "$_ > $gif_fn\n";
	### change ppm to gif
	`ppmtogif $_ > $gif_fn`;
	### remove the ppm file
	print `rm $_`;

	# move the original PS file to the ps/ directory
	`mv $ps_fn /users/asc/level2/data/mag/ps/`;
}
