PHPackages                             eigan/mediasort - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. eigan/mediasort

ActiveLibrary

eigan/mediasort
===============

A batch rename tool for media files

0.14(5y ago)30261[3 issues](https://github.com/eigan/mediasort/issues)[1 PRs](https://github.com/eigan/mediasort/pulls)PHPPHP &gt;=7.2

Since Oct 24Pushed 4y ago1 watchersCompare

[ Source](https://github.com/eigan/mediasort)[ Packagist](https://packagist.org/packages/eigan/mediasort)[ RSS](/packages/eigan-mediasort/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (6)Dependencies (7)Versions (11)Used By (0)

[![Tests](https://github.com/eigan/mediasort/workflows/CI/badge.svg)](https://github.com/eigan/mediasort/workflows/CI/badge.svg)[![Coverage](https://camo.githubusercontent.com/4915a60cf181e7543cc91c41c6ea3ce198669717395966a2de8071c74c8a8b95/68747470733a2f2f636f6465636f762e696f2f67682f656967616e2f6d65646961736f72742f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/eigan/mediasort)

Mediasort
---------

[](#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.

[![](mediasort.gif)](mediasort.gif)

- [Example](#example)
- [Installation](#installation)
    - [Requirements](#requirements)
    - [Arch Linux](#arch-linux)
- [Usage](#usage)
    - [Options](#options)
- [About](#about)
    - [Speed](#speed)
    - [Date and time from files](#date-and-time-from-files)
    - [File name collision](#file-name-collision)
    - [Step by step (internal)](#step-by-step-internal)
- [Tips](#tips)
    - [Remove empty directories](#remove-empty-directories)

### Example

[](#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](#options)

##### Before

[](#before)

```
source
├── IMG_20170331_180220.jpg
├── IMG_20170802_183621.jpg
├── IMG_20170802_183630.jpg
├── IMG_20170802_183634.jpg
└── VID_20171002_084709.mp4

```

##### After

[](#after)

Files are moved into `destination/` (create hardlinks with `--link`)

```
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

[](#installation)

See the [wiki page](https://github.com/eigan/mediasort/wiki/Installation).

#### Requirements

[](#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

[](#arch-linux)

Mediasort is available through AUR: [mediasort](https://aur.archlinux.org/packages/mediasort/).

#### Composer (global)

[](#composer-global)

```
composer global require eigan/mediasort

```

### Usage

[](#usage)

#### Options

[](#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.

### About

[](#about)

#### Date and time from files

[](#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

If no dates are found, then the format fails and file is skipped.

#### File name collision

[](#file-name-collision)

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

#### Step by step (internal)

[](#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

[](#tips)

#### Remove empty directories

[](#remove-empty-directories)

```
find . -type d -empty -delete

```

### Todo

[](#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

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 99.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~157 days

Recently: every ~236 days

Total

7

Last Release

2139d ago

PHP version history (2 changes)0.11PHP &gt;=7.0

0.14PHP &gt;=7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/2dae8f7b48971269ab62f5200a903f4998d72f36a29cfd5cfd43c05b3f24b2a8?d=identicon)[eigan](/maintainers/eigan)

---

Top Contributors

[![eigan](https://avatars.githubusercontent.com/u/41789?v=4)](https://github.com/eigan "eigan (156 commits)")[![wckd](https://avatars.githubusercontent.com/u/145903?v=4)](https://github.com/wckd "wckd (1 commits)")

---

Tags

batch-renamedirectory-managementmediasortorganizeorganize-photosrename

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/eigan-mediasort/health.svg)

```
[![Health](https://phpackages.com/badges/eigan-mediasort/health.svg)](https://phpackages.com/packages/eigan-mediasort)
```

###  Alternatives

[laravel/framework

The Laravel Framework.

34.6k509.9M17.0k](/packages/laravel-framework)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[magento/community-edition

Magento 2 (Open Source)

12.1k52.1k10](/packages/magento-community-edition)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[magento/magento2-functional-testing-framework

Magento2 Functional Testing Framework

15511.5M30](/packages/magento-magento2-functional-testing-framework)[wheelpros/fitment-platform-api

Magento 2 (Open Source)

12.1k1.2k](/packages/wheelpros-fitment-platform-api)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
