My main modification to the script above is getting all the variants instead of the first variant.$fn1 = 'db/products_id.csv'; // output fileif (file_exists($fn1)) {rename($fn1, rtrim($fn1, ".csv") . date("ymdHi") . ".csv") ; // rename file}ini_set('...