Giter Site home page Giter Site logo

media_divider's Introduction

Media Divider

This Python script frees Kodi media folders from unnecessary waste. This means after a run:

  • all empty folders are deleted
  • all folders without media files are deleted
  • all non-media files within the media folders and subfolders are deleted

Media files are:

  • Files with extension ending in .MKV, .ISO, .MP4, .MPG, .MPEG, .MOV, .H264, .H265, .TS, .PDF, .FLAC, .WAV, .OGG, .MP3
  • Files with filesize larger then 100MB

I would like to point out that if you use this script incorrectly, most of the movies, audio files and pictures would be deleted and are gone forever.

Usage (e.g. LibreElec):

python default.py media=/storage/videos action=dry-run

Params:

media:      <root folder> from where starts cleaning recursively
action:     dry-run | execute

This is a 'dry run', i.e. only files that would be deleted are listed or exceptions are displayed. Before you trigger the executive run, you absolutely have a look at the generated output on dry-run.
If there are files/folders that you don't want to delete, there are several options:

  • Complete folders including subfolders can be excluded by creating a (hidden) file named .donotdelete in the folder. The dot (.) in front of the .donotdelete is important!
  • excluded file formats or directories can be permanently inserted in the script itself (line 4/5)
  • additional excluded file types/formats can be added optionally to the call by parameter 'exclude'

Example (excluding files with extension .NFO, .IDX, .PNG; naming is case-insensitive). Separate extensions with space only and use a dot (.) in front of file extensions!

python default.py media=/storage/videos action=dry-run exclude=".nfo .idx .png"

If the dry run was successful and there are no files that shouldn't be deleted in the generated list, you can do a 'hot' run. ATTENTION: Files will be deleted without asking you, in a following 2nd run also all empty directories!

python default.py media=/storage/videos action=execute exclude=".nfo .idx .png"

After this run, there are only files in the media folders with the file extensions listed above (including the exclude files) or larger than 100 MB. This also applies to files in folders + subfolders that have a .donotdelete in the directory. Empty folders are disappeared.

It is completely useless to apply the script to the pictures folder, all jpg, jpeg, tif, png etc. are deleted then! Likewise, it makes also no sense to think 'bulk cleaning' is media =/storage. After that you are allowed to reinstall your system!

I assume no liability, everyone must know what he does! Making a backup before or - having at least one - is always useful!

media_divider's People

Contributors

b-jesch avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.