25 lines
670 B
PHP
25 lines
670 B
PHP
|
<?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");
|
||
|
}
|
||
|
?>
|