-
Notifications
You must be signed in to change notification settings - Fork 0
/
rename_covers.php
63 lines (48 loc) · 1.34 KB
/
rename_covers.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
<!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';
$covers = array_filter(glob('e:\projects\shopify\covers\\' . '*.jpg'), 'is_file');
$failed = array();
foreach ($covers as $cover) {
$cover_ascii = \Patchwork\Utf8::toAscii($cover);
if(rename($cover, $cover_ascii)){
echo $cover . " => $cover_ascii <br>";
} else {
echo $cover . " RENAME FAILED <br>";
$failed[] = $cover;
}
}
echo "=========================<br>";
echo "FAILED" . count($failed) ." <br>";
function dirSize($directory) {
$size = 0;
foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $file){
$size+=$file->getSize();
}
return $size;
}
die();
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>