#!usr/local/bin/perl

opendir ($ARGV[0], "output");
chdir (output);
open (OUTFILE, ">log.txt");

while ($filename = readdir (output)){
	if ($filename == ".") {
		$filename = readdir (output);
	}
	else { open (FILE, $filename) ||
			die ("Cannot open file $filename\n");
			print ("Opening $filename\n");
		$linha = <FILE>;
		$pula_linha = 0;
		while ($pula_linha < 1) {
			$linha = <FILE>;
			$pula_linha++;
			}
		@getting_name = split (/!/, $linha);
		@getting_name = split (/=/, $getting_name[1]);
				
		rename ($filename, "$getting_name[1]=$getting_name[2]");
	}
}
