-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_files2.php
81 lines (59 loc) · 1.78 KB
/
test_files2.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<?php
require 'models'.DIRECTORY_SEPARATOR.'Track.php';
require 'Utf8.php';
$dirs = array_filter(glob(Track::$search_tracks_in . '*'), 'is_dir');
foreach ($dirs as $dir) {
$dir_basename = basename($dir);
$dir_ascii = \Patchwork\Utf8::toAscii($dir_basename);
echo $dir . " => $dir_ascii <br>";
if(rename($dir, $dir_ascii)){
echo $dir . " => $dir_ascii <br>";
} else {
echo $dir . " RENAME FAILED <br>";
}
}
function dirSize($directory) {
$size = 0;
foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $file){
$size+=$file->getSize();
}
return $size;
}
die();
Config::getConfig();
$tracks = Track::find('all'/*, array('conditions' => 'id = 1')*/);
$not_found_files = 1;
foreach ($tracks as $track) {
$full_track_path = Track::$search_tracks_in . stripSpaces($track->composer->name) . DIRECTORY_SEPARATOR . stripSpaces($track->name_ascii) . '.mp3';
if(!is_file($full_track_path)){
echo "$full_track_path<br>";
$not_found_files++;
}
// $track->name_ascii = trim($track->name_ascii);
// $track->save();
}
echo "Missing $not_found_files files";
function humanFileSize($size, $unit = "")
{
if ((!$unit && $size >= 1 << 30) || $unit == "GB")
return number_format($size / (1 << 30), 2) . "GB";
if ((!$unit && $size >= 1 << 20) || $unit == "MB")
return number_format($size / (1 << 20), 2) . "MB";
if ((!$unit && $size >= 1 << 10) || $unit == "KB")
return number_format($size / (1 << 10), 2) . "KB";
return number_format($size) . " bytes";
}
function stripSpaces($str)
{
return str_replace(' ', '_', $str);
}
?>
</body>
</html>