AbelCam Forum
Download AbelCam buy Pro
 
 
 
Welcome Anonymous User
04/29/2024 - 05:52 AM
Quick Search:
Quick Jump:
 
Announcements
Latest Topics
 
Put captures in a folder-structure
By: JeanMu
Rank: Frequent User
Topics: 16
From: CH
Added: 08/21/2010 - 03:14 AM

Hi
I would like to have all the captured images in a folder structure instead of one flat folder wit thousands of files.

Example

D:\Captures\2010\08\21\20100821013152.jpg

or

D:\Captures\2010\08\21\013152.jpg

Or has anyone some tools or scripts that would help to organize alle the files during the night ?

Jean-Marc
By: MelvinG
Rank: Magna Cum Laude
Topics: 661
From: Los Angeles, USA
Added: 08/27/2010 - 04:51 AM

Glad to see you guys are interested in this script. Feel free to use and modify it as you see fit.

When you try it out please keep in mind the following things:

(1) For the PHP version, you will need to change a line of code near the beginning that controls time zone calcs:

date_default_timezone_set("America/Los_Angeles");

should be changed to reflect your actual location. See http://www.php.net/manual/en/timezones.php to find the "Country/City" string that should be used for your location.

(2) For both PHP and Perl versions, the line at the beginning of the script that defines the path to your AbelCam config.xml may need to be changed to agree with your installation. There was talk upthread about automating this but I haven't done so yet. I'm uneasy about trying to automate since XP, Vista and 7 are all different and I don't have all of them here to test on.
By: JeanMu
Rank: Frequent User
Topics: 16
From: CH
Added: 08/30/2010 - 05:24 PM

Hi Melvin and others.
Today I had time to test the script. I use the php version. I tuned it allready a bit. First I changed the first lines to find the config to this:

$config = str_replace("\\" ,"/",str_replace(getenv("USERPROFILE"),getenv("ALLUSERSPROFILE"),getenv("APPDATA")));
$config = $config."/seiz system engineering/abelcam/config.xml";
This should be universal to use on any system. Then I added the same search for directorys in the videosave.xml to sort also the videos. The final version looks like this:
<?php

///////// YOU MUST CHANGE THESE LINES TO AGREE WITH YOUR SYSTEM CONFIGURATION /////////
$config = str_replace("\\" ,"/",str_replace(getenv("USERPROFILE"),getenv("ALLUSERSPROFILE"),getenv("APPDATA")));
$config = $config."/seiz system engineering/abelcam/config.xml";

date_default_timezone_set("Europe/Zurich"); 
// See: http://www.php.net/manual/en/timezones.php for list of php time zones.

/////////

// Dig any/all localsave paths out of AbelCam Configs
$cfg_xml = simplexml_load_file($config);
$dev_dirs = $cfg_xml->DeviceFolders->string;

foreach($dev_dirs as $dev_dir) {
    if (strlen($dev_dir) > 0) {
        if (substr($dev_dir, -1) != "\\") {
            $dev_dir .= "\\";
        }
        $dev_xml=simplexml_load_file($dev_dir . "localsave.xml");
        if (strlen($dev_xml->LocalSaveDir) > 0) {
            if (substr($dev_xml->LocalSaveDir, -1) != "\\") {
                $dev_xml->LocalSaveDir .= "\\";
            }
            $save_dirs[] = $dev_xml->LocalSaveDir;
        }
		$dev_xml=simplexml_load_file($dev_dir . "videosave.xml");
        if (strlen($dev_xml->svdirectory) > 0) {
            if (substr($dev_xml->svdirectory, -1) != "\\") {
                $dev_xml->svdirectory .= "\\";
            }
            $save_dirs[] = $dev_xml->svdirectory;
        }
    }
}
if (count($save_dirs) == 0) {
    print "No useable AbelCam configs found. Exiting.\n";
    exit;
}

$yesterday = localtime(time() - 86400);
$YDyear    = $yesterday[5];
$YDyday    = $yesterday[7];

// Process each localsave directory
foreach ($save_dirs as $save_dir) {
    print ("\n\nExamining $save_dir\n");
    chdir($save_dir);
    $files = glob("{*.jpg,*.JPG,*.wmv,*.WMV}", GLOB_BRACE);
    $file_cnt = 0;

    // Examine each .jpg file in the dir
    foreach ($files as $file) {
        $fmtime = localtime(filemtime($file));
        $FMyear = $fmtime[5];
        $FMyday = $fmtime[7];

        // Is this file old enough to move?
        if ($FMyear < $YDyear || $FMyday <= $YDyday) {
            $FMyear += 1900;
            $FMmon  = $fmtime[4] + 1;
            $FMmon  = ($FMmon < 10) ? "0$FMmon" : "$FMmon";
            $FMmday = $fmtime[3];
            $FMmday = ($FMmday < 10) ? "0$FMmday" : "$FMmday";
            $dest   = $save_dir . "$FMyear\\$FMmon\\$FMmday";

            // If destination dir does not exist, create it
            if (!file_exists($dest)) {
                print "Will create $dest\n";
                if (mkdir($dest, 0, TRUE)) {
                    print "Create dir succeeded\n";
                }
                else {
                    print "Create dir FAILED!!\n";
                    continue;
                }
            }

            // Finally, move the file
            if(rename($file, "$dest\\$file")) {$file_cnt++;}

        } //if file is old

    } // foreach file

    // Report what we did
    if ($file_cnt == 0) {
        print "Nothing to do here\n";
    }
    else {
        print "Moved $file_cnt files\n";
    }

} // foreach save_dir

?>


Works great!
Thanks a lot!
Jean-Marc
By: MelvinG
Rank: Magna Cum Laude
Topics: 661
From: Los Angeles, USA
Added: 08/31/2010 - 02:13 AM

Glad you like it, and thanks for posting the tuning tip for PHP version. I sorted it out for Perl but forgot about PHP.

The Time Zone line in the PHP code is annoying but without it PHP complains. I believe it is possible to eliminate that line IF the default time zone is already set by a php.ini entry. But asking the user to change php.ini is no better than asking him to change a line in the script, and Time Zone is not in php.ini by default... Sad
By: JeanMu
Rank: Frequent User
Topics: 16
From: CH
Added: 02/20/2011 - 03:17 AM

I am very happy with the script. It's running for a long time now without any problems. But I would now like to have a gallery reachable from the web. While looking for a script to do this I found a installable gallery built in to the installer of AbelCam mentioned here: http://www.abelcam.com/en/abelwiki/HowToUsePHP. But I can't found it ! Where is it gone ?
By: sse
Rank: Forum Addict
Topics: 73
From: n/a
Added: 02/23/2011 - 06:10 PM

Looks like the gallery dropped out of the installer.
You can download it from here

On to the original subject of this thread:
The next beta release of AbelCam will support storing images into folders organized by date and time.
By: sse
Rank: Forum Addict
Topics: 73
From: n/a
Added: 02/25/2011 - 02:46 PM

The latest AbelCam, 4.1.6, includes the PHP image gallery again.

Also, it allows to organize Local Save and FTP Upload images in a freely configurable date/time folder structure.