mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-03 01:39:24 +02:00
Improve query cache
This commit is contained in:
parent
1b2c14df5f
commit
230d6b255f
1 changed files with 56 additions and 0 deletions
56
install/moveFilesToFolder2.php
Normal file
56
install/moveFilesToFolder2.php
Normal file
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
//streamer config
|
||||
require_once '../videos/configuration.php';
|
||||
|
||||
if (!isCommandLineInterface()) {
|
||||
return die('Command Line only');
|
||||
}
|
||||
|
||||
set_time_limit(300);
|
||||
ini_set('max_execution_time', 300);
|
||||
|
||||
$global['rowCount'] = $global['limitForUnlimitedVideos'] = 999999;
|
||||
$path = getVideosDir();
|
||||
$logFile = $global['logfile'];
|
||||
echo "Open $logFile" . PHP_EOL;
|
||||
$handle = fopen($logFile, "r");
|
||||
|
||||
$pattern = '/Video::updateDirectoryFilename video folder renamed from \[olddir=(.+)\] \[newdir=(.+)\]/';
|
||||
|
||||
if ($handle) {
|
||||
while (($line = fgets($handle)) !== false) {
|
||||
if (preg_match($pattern, $line, $matches)) {
|
||||
//var_dump($matches);
|
||||
if (!is_dir($matches[2])) {
|
||||
continue;
|
||||
}
|
||||
$glob = glob("{$matches[1]}*");
|
||||
$totalItems = count($glob);
|
||||
echo "Found total of {$totalItems} items " . PHP_EOL;
|
||||
$countItems = 0;
|
||||
foreach ($glob as $file) {
|
||||
if (is_dir($file)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$pathInfo = pathinfo($file);
|
||||
$sourceFilename = Video::getCleanFilenameFromFile($file);
|
||||
$filename = Video::getCleanFilenameFromFile($matches[2]);
|
||||
|
||||
$basename = str_replace($sourceFilename, $filename, $pathInfo['basename']);
|
||||
|
||||
$destinationFile = "{$matches[2]}{$basename}";
|
||||
|
||||
//var_dump($pathInfo, $basename,$filename, $sourceFilename, $destinationFile);
|
||||
$countItems++;
|
||||
echo "[$countItems/$totalItems] move file {$file} to {$destinationFile}" . PHP_EOL;
|
||||
rename($file, $destinationFile);
|
||||
}
|
||||
}
|
||||
// process the line read.
|
||||
}
|
||||
|
||||
fclose($handle);
|
||||
} else {
|
||||
// error opening the file.
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue