Coder Social home page Coder Social logo

bulkrename's Introduction

bulkrename

The underlying design features a modular, dynamic approach to generating filenames and ships with a variety of specialized modules for renaming e.g. fonts or images, and more general ones - such as content-digests, simple counters or regex captures.

See the examples below, to get an idea of how everything works!

Usage

bulkrename -[vqc] [-l LIMIT] [-m MODULE ARGS] [-f FORMAT] [FILE [FILE..]]
bulkrename --help

Files are renamed in accordance with the given FORMAT string. If no FORMAT is specified, the output will exactly match the input. By default no action is taken and a list of planned changes is printed. Pass --commit to actually rename files.

In order to keep a good performance profile modules must be enabled explicitly to be used and some modules accept additional flags to control their output.

Installation

$ git clone https://github.com/4nickel/bulkrename
$ cd bulkrename
$ pip install --user -r requirements.txt

Modules

Module Description Arguments ย 
hash Content digest --algorithm [md5|sha256] Select algorithm
mime Try to detect MIME type
number Simple counter --number N Start counting from N
regex Capture via regex --regex REGEX Regex to use
stat Unix file stat command
image Image dimensions
font Font information

Formatting

default

Format Description
name Contains the original file name, without extension
ext Contains the original extension. May be empty

hash

Format Description
hash The content digest

mime

Format Description
mime Best-effort guess of the MIME-type. May be incorrect!

number

Format Description
number The number N of the file

regex

The regex will be run against every file name. You can access any named capture group in the format string. Very flexible and powerful.

stat

Format Description
mode File mode
inode Inode number
device Device
nlink Number of hardlinks
uid User ID
gid Group ID
size Size in bytes
atime Last accest time
mtime Last modification time
ctime Birth time

image

Format Description
width The width of the image file in pixels
height The height of the image file in pixels
ratio The ratio of width to height

Examples

Add prefix/suffix:

$ bulkrename -f 'prefix-{name}{ext}' -- ..files..
$ bulkrename -f '{name}-suffix{ext}' -- ..files..

Content digest - in this case the md5 algorithm is used:

bulkrename -m hash -a md5 -f '{hash}{ext}' -- ..files..

Incrementing counter - files are numbered in the order they appear as arguments:

bulkrename -m number '{number}{ext}' -- ..files..

Rename with regex:

bulkrename -m regex -r '(?P<capture>.*)' -f 'your.{capture}.here' -- ..files..

Fix mime types:

bulkrename -m mime -f '{name}{mime}' -- ..files..

Add mtime or other file stats:

bulkrename -m stat -f '{name}-{mtime}{ext}' -- ..files..

Image width and height:

bulkrename -m image -f '{name}_{width}x{height}{ext}' -- ..files..

bulkrename's People

Contributors

4nickel avatar dependabot[bot] avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

new4beeeee

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.