rendered paste body#!/usr/local/bin/php
<?php
$path = "/rbackup/.CAM/";
if (is_dir($path)) {
if ($cams = opendir($path)) {
while (($camdirs = readdir($cams)) !== false) {
if (filetype($path.$camdirs) == "dir" && $camdirs != "." && $camdirs != "..") {
if ($dh = opendir($path.$camdirs."/")) {
while (($file = readdir($dh)) !== false) {
if (filetype($path.$camdirs."/".$file) == "file") {
$id = substr($file,0,4);
$year = substr($file,5,4);
$month = substr($file,9,2);
$day = substr($file,11,2);
$hour = substr($file,13,2);
$min = substr($file,15,2);
$sec = substr($file,17,2);
$hour2 = $hour+1;
if (!is_dir($path."/".$id)) {
echo "Opretter $path/$id\n";
mkdir($path."/".$id);
}
if (!is_dir($path."/".$id."/".$year."-".$month."-".$day)) {
echo "Opretter $path/$id/$year.$month.$day\n";
mkdir($path."/".$id."/".$year."-".$month."-".$day);
}
if (!is_dir($path."/".$id."/".$year."-".$month."-".$day."/".$hour."-".$hour2)) {
echo "Opretter $path/$id/$year.$month.$day/$hour\n";
mkdir($path."/".$id."/".$year."-".$month."-".$day."/".$hour."-".$hour2);
}
//echo "$id $year $month $day $hour $min $sec\n";
echo "Goes in ".$id."/".$year."-".$month."-".$day."/".$hour."-".$hour2."\n";
rename($path.$id."/".$file, $path.$id."/".$year."-".$month."-".$day."/".$hour."-".$hour2."/".$file);
}
}
closedir($dh);
}
}
}
}
closedir($cams);
}
?>