2017 © Pedro Peláez
 

library media-organizer

Organize images and videos (or any files) into date-based folders.

image

aensley/media-organizer

Organize images and videos (or any files) into date-based folders.

  • Monday, December 18, 2017
  • by awensley
  • Repository
  • 1 Watchers
  • 1 Stars
  • 29 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

MediaOrganizer

Organize images and videos (or any files) into date-based folders., (*1)

MIT License Build Status Maintainability Test Coverage Latest Stable Version Packagist Downloads, (*2)

What it does

Description for the impatient reader: This library moves files from one place to another., (*3)

Detailed description: This library helps organize files into date-based folders. The date is retrieved from each file in a number of configurable ways. The structure of the date-based folders can be designed any way you want., (*4)

This was primarily written to organize JPG images, but it will work for files of any type. Available date-retrieval methods are:, (*5)

  1. EXIF - Retrieve the date from the file's EXIF data (JPG and TIFF images only).
  2. File Name Masks - Match date/time patterns in the name of the file.
  3. Modified Time - Use the file's "last modified" time. This property is set by the operating system and is often not as reliable as the first two.

Installation

Install the latest version with, (*6)

composer require aensley/media-organizer

Options

Profiles

You can specify any number of profiles to process. They will be processed in order. Each profile can have its own separate options. Available options are documented in the code., (*7)

Logger

You can specify a logger object implementing the PRS-3 Logger Interface for custom handling of log messages. I recommend Monolog (and monolog-colored-line-formatter for bonus points in bash)., (*8)

Otherwise, you can specify a log level string (one of: 'none', 'error', 'warning', 'info', 'debug') to use the simple internal logger. The internal logger directly echoes messages followed by newline characters \n., (*9)

Requirements

  • PHP >= 7.1

Example usage

Simple example

<?php

require '/path/to/composer/autoload.php';

$organizer = new \Aensley\MediaOrganizer\MediaOrganizer(
    array(
        'images' => array(
            'source_directory' => '/data/unorganized_pictures/',
            'target_directory' => '/data/Organized/Pictures/',
            'valid_extensions' => array('jpg'),
        ),
        'videos' => array(
            'source_directory' => '/data/unorganized_videos/',
            'target_directory' => '/data/Organized/Videos/',
            'valid_extensions' => array('mp4'),
            'scan_exif' => false,
        ),
    ),
    'debug'
);

$organizer->organize();

Advanced Usage

<?php

require '/path/to/composer/autoload.php';

use \Monolog\Logger;
use \Monolog\Handler\StreamHandler;
use \Bramus\Monolog\Formatter\ColoredLineFormatter;
use \Aensley\MediaOrganizer\MediaOrganizer;

$logger = new Logger('mediaOrganizer');
// Colored output in Bash
$handler = new StreamHandler('php://stdout', Logger::DEBUG);
$handler->setFormatter(new ColoredLineFormatter());
$logger->pushHandler($handler);
// Put everything in a log file, too.
$logger->pushHandler(new StreamHandler('/var/log/mediaOrganizer/mediaOrganizer.log', Logger::DEBUG));

$organizer = new MediaOrganizer(
    array(
        'images' => array(
            'source_directory' => '/data/unorganized_pictures/',
            'target_directory' => '/data/Organized/Pictures/',
            'valid_extensions' => array('jpg'),
        ),
        'videos' => array(
            'source_directory' => '/data/unorganized_videos/',
            'target_directory' => '/data/Organized/Videos/',
            'valid_extensions' => array('mp4'),
            'scan_exif' => false,
        ),
        'gifs' => array(
            'source_directory' => '/data/unorganized_gifs/',
            'target_directory' => '/data/Organized/Gifs/',
            'valid_extensions' => array('gif'),
            'scan_exif' => false,
            'file_name_masks' => false,
            'modified_time' => true,
            'search_recursive' => true,
            'target_mask' => 'Y/F/d',
            'overwrite' => true,
        ),
    ),
    $logger
);

$organizer->organize();

The Versions

18/12 2017

dev-dependabot/composer/satooshi/php-coveralls-1.1.0

dev-dependabot/composer/satooshi/php-coveralls-1.1.0 https://github.com/aensley/media-organizer/

Organize images and videos (or any files) into date-based folders.

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

image video media mp4 jpg

18/12 2017

dev-dependabot/composer/monolog/monolog-1.23.0

dev-dependabot/composer/monolog/monolog-1.23.0 https://github.com/aensley/media-organizer/

Organize images and videos (or any files) into date-based folders.

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

image video media mp4 jpg

19/10 2017

dev-master

9999999-dev https://github.com/aensley/media-organizer/

Organize images and videos (or any files) into date-based folders.

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

image video media mp4 jpg

07/07 2016

1.0.2

1.0.2.0 https://github.com/aensley/media-organizer/

Organize images and videos (or any files, really) into date-based folders.

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

image video media mp4 jpg

06/07 2016

1.0.1

1.0.1.0 https://github.com/aensley/media-organizer/

Organize images and videos (or any files, really) into date-based folders.

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

image video media mp4 jpg

06/07 2016

1.0.0

1.0.0.0 https://github.com/aensley/media-organizer/

Organize images and videos (or any files, really) into date-based folders.

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

image video media mp4 jpg