query("SELECT trackinfo FROM storage_files"); while($datalist = $result->fetchArray(SQLITE3_ASSOC)) { $content = json_decode($datalist['trackinfo'], true); $path = $content['path']; if(file_exists("storage/".$path)) { $filelocation = "storage/".$path; $name = $content['title']; nameFile($filelocation, $name); } echo "

All files in /storage renamed and fixed up. \n

Output is in /output/songnames/"; $db->close(); } function nameFile($file, $name) { $fname = preg_replace('/[^A-Za-z0-9- \-]/', '', $name); rename($file, "output/".utf8_decode($fname).".mp3"); } ?>