<?php 
$filePath = "./allDesc.txt";
$myfile = fopen($filePath, "r") or die("Unable to open file!");
$allDesc = fread($myfile,filesize($filePath));
fclose($myfile);

$allDescByChar = explode("\n", $allDesc);
	
for ($i = 1; $i <= 270; $i++){
	// $race = $i <= 90 ? 'Guardian' : ($i <= 180 ? 'Human' : 'Demon');
	// $newAttributes = array(
		// 'trait_type' => 'Race',
		// 'value' => $race
	// );
	
	// $filePath = "./$i";
	// $myfile = fopen($filePath, "r") or die("Unable to open file!");
	// $json = fread($myfile,filesize($filePath));
	// fclose($myfile);
	
	// $metadata = json_decode($json);
	// array_push($metadata->attributes, $newAttributes);
	// file_put_contents($i, json_encode($metadata));
	
	$filePath = "./$i";
	$myfile = fopen($filePath, "r") or die("Unable to open file!");
	$json = fread($myfile,filesize($filePath));
	fclose($myfile);
	
	$metadata = json_decode($json);
	
	$desc = str_replace("\r", '', $allDescByChar[$i - 1]);
	$desc = str_replace("\n", '', $desc);
	
	$data = array( 
		'name' => $metadata->name,
		//'description' => $metadata->description,
		'description' => $desc,
		'image' => $metadata->image,
		'turntable' => 'http://miracledev.net/bog/turntable/'.$i.'.mp4',
		'promotionalImg' => 'http://miracledev.net/bog/promotionalImg/'.$i.'.png',
		'external_url' => $metadata->external_url,
		'attributes' => $metadata->attributes
	);
	file_put_contents($i, json_encode($data));
}
?>