Skip to main content

A cross-platform module for sorting files by time.

Project description

mtsort

A cross-platform module for sorting files by time.

PyPI version GitHub license

Gets last modification time from file(s) and folder(s), then moves them to a new directory, sorting them in new folders. These folder names are in 'yyyy-mm-dd' format.

Useful for sorting large collections of files, which would be otherwise tedious to do manually!

Tested and confirmed working on Python 3.6 and above.

Installation

pip install mtsort

or with the installation script:

python3 setup.py install

Examples

Moving files:

>>> import mtsort
>>> mtsort.mtmove('/home/test/sourcedir', '/home/test/destdir')

Results in:

    before:                after:
    .                      .
    |-- destdir            |-- destdir
    |-- sourcedir          |   |-- 2016-07-29  
        |-- file1          |   |   |-- file1
        |-- file2          |   |-- 2016-07-30
        |-- file3          |   |   |-- file2
                           |   |-- 2016-07-31
                           |       |-- file3
                           |-- sourcedir

Copying files:

>>> import mtsort
>>> mtsort.mtcopy('/home/test/sourcedir', '/home/test/destdir')

Results in:

    before:                after:
    .                      .
    |-- destdir            |-- destdir
    |-- sourcedir          |   |-- 2016-07-29  
        |-- file1          |   |   |-- file1
        |-- file2          |   |-- 2016-07-30
        |-- file3          |   |   |-- file2
                           |   |-- 2016-07-31
                           |       |-- file3
                           |-- sourcedir
                               |-- file1
                               |-- file2
                               |-- file3

Alternatively, you can simply launch the script on its own, or from the command line to use it:

from terminal:

$ mtsort

from cmd or Powershell:

C:\> py -m mtsort

Project details


Release history Release notifications

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
mtsort-1.0.1-py3-none-any.whl (3.7 kB) Copy SHA256 hash SHA256 Wheel py3
mtsort-1.0.1.tar.gz (3.3 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page