2017 © Pedro Pelรกez
 

library mediasort

A batch rename tool for media files

image

eigan/mediasort

A batch rename tool for media files

  • Wednesday, July 11, 2018
  • by eigan
  • Repository
  • 1 Watchers
  • 18 Stars
  • 11 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 2 Open issues
  • 27 Versions
  • 0 % Grown

The README.md

Tests Coverage, (*1)

Mediasort

A batch rename tool for media files (audio, video and images). Move, or create an hardlink, with a new name based on meta information extracted from the file., (*2)

, (*3)

Example

mediasort source/ destination/
  • destination is optional.
  • --format=":year/:month/:date :time" default format of new filenames

Common options - -r for recursive - --link for using hardlinks - -n for no interaction (autoconfirm) - -q quiet - See more options, (*4)

Before
source
โ”œโ”€โ”€ IMG_20170331_180220.jpg
โ”œโ”€โ”€ IMG_20170802_183621.jpg
โ”œโ”€โ”€ IMG_20170802_183630.jpg
โ”œโ”€โ”€ IMG_20170802_183634.jpg
โ””โ”€โ”€ VID_20171002_084709.mp4
After

Files are moved into destination/ (create hardlinks with --link), (*5)

destination
โ””โ”€โ”€ 2017
    โ”œโ”€โ”€ 03 - March
    โ”‚ย ย  โ””โ”€โ”€ 2017-03-31 18:02:20.jpg
    โ”œโ”€โ”€ 08 - August
    โ”‚ย ย  โ”œโ”€โ”€ 2017-08-02 18:36:22.jpg
    โ”‚ย ย  โ”œโ”€โ”€ 2017-08-02 18:36:30.jpg
    โ”‚ย ย  โ””โ”€โ”€ 2017-08-02 18:36:35.jpg
    โ””โ”€โ”€ 10 - October
        โ””โ”€โ”€ 2017-10-02 08:47:09.mp4

Installation

See the wiki page., (*6)

Requirements

  • PHP 7.0.24+
    • ext-exif. For precise meta information (dates), and more.
    • ext-phar For composer (build from source), or to execute phar file

Arch Linux

Mediasort is available through AUR: mediasort., (*7)

Composer (global)

composer global require eigan/mediasort

Usage

Options

--format            Reformat the path
                    Example: --format=":year/:month/:date :time" (default)

                    Possible formatters:
                        :original (original path)
                        :date (alias ":year-:monthnum-:day")
                        :time (alias ":hour::minute::second")
                        :month (alias ":monthnum - :monthname")
                        :year
                        :monthnum
                        :monthname
                        :day
                        :hour
                        :minute
                        :second
                        :ext (not needed, always appended)
                        :name (original filename)
                        :dirname (name of original parent directory)

                    Exif is mostly used if available

-r, --recursive     Look for files recursively in source

--only              Only files with the given extensions
                    Example: --only="jpg,gif"

--only-type         Only files with the given filetype
                    Example: --type="image,video,audio" (default)

--link              Create hardlink instead of moving

-v                  Show additional information
-vv                 Show even more info (result for all formatters)

-n                  Disable interaction (Will autoconfirm)

--ignore            Ignore certain file extensions
                    Example: --ignore="db,db-journal"

--dry-run           Do not execute move/link

--no-exif           Do not read exif meta information

--log-path          Specify where to put mediasort.log
                    Default: null (no logging)

Note: shortcuts cannot be combined, -nv will not work. This is a limitation of the CLI library used., (*8)

About

Date and time from files

Date is retrieved from files in the following order: - exif meta information (image) - id3 meta information (video/audio) - Date in path matching pattern: - YYYYMMDD_HHMMSS - YYYY-MM-DD HH.mm.ss - YYYY-MM-DD HH:mm:ss - YYYYMMDDHHMMSS - YYYYMMDD-HHMMSS, (*9)

If no dates are found, then the format fails and file is skipped., (*10)

File name collision

When a file is identical, it gets ignored, otherwise we append an index to the filename., (*11)

Step by step (internal)

- Takes two arguments
  - `source`: Read files from here
  - `destination` (optional): Directory to populate. If not set, uses `source`
- Takes several options, see list above

-  Start look for media files in source
  - Skip files if:
    - Not a media file
    - Filtered by options
    - Is in built in ignorelist:
      - .nomedia, @eaDir

  - Generate a name based on the `--format` option
  - Check if the generated name exists
    - Check if duplicate
    - append an available "index" to the name

  - Move or link the media file into destination

Tips

Remove empty directories

find . -type d -empty -delete

Todo

These are things I would like to do sometime, but I don't really need right now. - Split code into more files. - More formatters - :type-s - :exif(ExifProp) - :path full original path - --filter=":size>10 & :name~/regex/ & :weekday=monday - I18n - Test Mac (travis) / Windows (tea-ci) - symlink, (*12)

The Versions

11/07 2018

dev-master

9999999-dev

A batch rename tool for media files

  Sources   Download

The Requires

 

The Development Requires

29/04 2018

0.12.2

0.12.2.0

A batch rename tool for media files

  Sources   Download

The Requires

 

The Development Requires

14/02 2018

0.12.1

0.12.1.0

A batch rename tool for media files

  Sources   Download

The Requires

 

The Development Requires

03/12 2017

0.12

0.12.0.0

A batch rename tool for media files

  Sources   Download

The Requires

 

The Development Requires

02/12 2017

0.11.1

0.11.1.0

A batch rename tool for media files

  Sources   Download

The Requires

 

The Development Requires

02/12 2017

0.11

0.11.0.0

A batch rename tool for media files

  Sources   Download

The Requires

 

The Development Requires

26/11 2017

2.2

2.2.0.0

A batch rename tool for media files

  Sources   Download

The Requires

 

The Development Requires

26/11 2017

2.1

2.1.0.0

A batch rename tool for media files

  Sources   Download

The Requires

 

The Development Requires

04/11 2017

2.0.1

2.0.1.0

A batch rename tool for media files

  Sources   Download

The Requires

 

The Development Requires

04/11 2017

2.0

2.0.0.0

A batch rename tool for media files

  Sources   Download

The Requires

 

The Development Requires

04/11 2017

1.8

1.8.0.0

A batch rename tool for media files

  Sources   Download

The Requires

 

The Development Requires

03/11 2017

1.7

1.7.0.0

A batch rename tool for media files

  Sources   Download

The Requires

 

The Development Requires

31/10 2017

1.6

1.6.0.0

A batch rename tool for media files

  Sources   Download

The Requires

 

The Development Requires

30/10 2017

1.5

1.5.0.0

A batch rename tool for media files

  Sources   Download

The Requires

 

The Development Requires

29/10 2017

1.4.1

1.4.1.0

A batch rename tool for media files

  Sources   Download

The Requires

 

The Development Requires

24/10 2017

1.4

1.4.0.0

A batch rename tool for media files

  Sources   Download

The Requires

 

The Development Requires

24/10 2017

1.3

1.3.0.0

A batch rename tool for media files

  Sources   Download

The Requires

 

The Development Requires

24/10 2017

dev-eg-checkinode

dev-eg-checkinode

A batch rename tool for media files

  Sources   Download

The Requires

 

The Development Requires

22/10 2017

1.2

1.2.0.0

A batch rename tool for media files

  Sources   Download

The Requires

 

The Development Requires

22/10 2017

1.1.4

1.1.4.0

A batch rename tool for media files

  Sources   Download

The Requires

 

The Development Requires

22/10 2017

1.1.3

1.1.3.0

A batch rename tool for media files

  Sources   Download

The Requires

 

The Development Requires

22/10 2017

1.1.2

1.1.2.0

A batch rename tool for media files

  Sources   Download

The Requires

 

The Development Requires

22/10 2017

1.1.1

1.1.1.0

A batch rename tool for media files

  Sources   Download

The Requires

 

The Development Requires

22/10 2017

1.1

1.1.0.0

A batch rename tool for media files

  Sources   Download

The Requires

 

The Development Requires

21/10 2017

1.0.2

1.0.2.0

A batch rename tool for media files

  Sources   Download

The Requires

 

The Development Requires

21/10 2017

1.0.1

1.0.1.0

A batch rename tool for media files

  Sources   Download

The Requires

 

The Development Requires

21/10 2017

1.0

1.0.0.0

A batch rename tool for media files

  Sources   Download

The Requires

 

The Development Requires