Coder Social home page Coder Social logo

kigster / treename Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 44 KB

Rename all files in multi-level folder tree based on custom logic, with optional custom callbacks. Use it to process batches of files to convert them eg. from WAV to MP3 or vice versa, while renaming them along the way.

License: MIT License

Ruby 100.00%

treename's Introduction

TreeName — Recursive File Renaming Ruby Gem with CLI

Ruby Build Status Coverage

Using treename

$ treename --help

TreeName CLI 0.1.2
© 2020 Konstantin Gredeskoul, All rights reserved. MIT License.

Commands:
  treename ls [FOLDER] [PATTERN]                 # Print matching file info
  treename version                               # Print version

Commands

ls

Arguments:

  • folder - a root directory of the multi-level tree.

  • pattern — a file glob pattern, for instance **/*.mp3

This command simply prints all files matching the patter under the folder.

Important
The file paths are printed relative to the folder argument.

Example:

❯ treename ls ~/Music **/*.mp3
Music/Media.localized/LeftCtrl/Left Turn Right Turn EP/Nevada Lazy Sunday Beat Cakes.mp3
Music/Media.localized/LeftCtrl/2017 NYE @ F&J/LeftCtrl @ NYE 2017.mp3
Logic Bounces/Final Cut Original Media/2017-01-05/LeftCtrl @ NYE 2017.mp3

This means that, for instance, I have a Music folder under my ~/Music folder :)

copy-rename aka cpr

Important
not yet implemented.

This command will create a mirror folder tree with the files renamed. It does not change the original files.

Examples:

treename cpr ~/Music **/*.mp3 --dest=~/NewMusic --strategy-file=rename.yml

Strategy file looks like this:

cpr:
  files:
    actions:
    - replace: [ ' ', '-' ]
    - replace: [ '---', '-' ]
    - extract:
        token: bpm
        regex: (\d+)bpm
        match: $1
    - rename: '{{ bpm }}.{{ basename }}.mp3'

© 2020 Konstantin Gredeskoul, MIT License.

treename's People

Stargazers

 avatar

Watchers

 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.