You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
670 B

<?php
session_start();
$db = new SQLite3("db.db");
$result = $db->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 "<h1>All files in /storage renamed and fixed up. \n <p>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");
}
?>