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


Download files

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

Source Distribution

mtsort-1.0.1.tar.gz (3.3 kB view hashes)

Uploaded Source

Built Distribution

mtsort-1.0.1-py3-none-any.whl (3.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page