MetaMove is written in Python3 and aims at easing batch renaming operations based on file meta data.

Overview

MetaMove

MetaMove is written in Python3 and aims at easing batch renaming operations based on file meta data.

MetaMove abuses eval combined with f-strings. It's some sort of wrapper, that handles file operations and requires a Python3 format string generate new file names.

python3 metamove.py --type f --dry --name "test/**" "test1/{name}-{int(stat.st_mtime)}.{ext}"

Usage

usage: metamove.py [-h] [-R] [--type {f,d}] [--name NAME] [--dry] [--regex REGEX] pattern

positional arguments:
  pattern          destination directory with Python f-string for renaming operations, e.g. "test1/{name}-{int(stat.st_mtime)}.{ext}"

optional arguments:
  -h, --help       show this help message and exit
  -R, --recursive  Activating this switch will traverse recursively through subdirectories.
  --type {f,d}     "f" for file or "d" for directory, defaults to both
  --name NAME      glob that will match on files, similar to "find -name *.txt"
  --dry            do not actually do anything but showing the result
  --regex REGEX    regex to extract filename parts, can be accessed in the 'pattern' using the 'regex' array

Curly braces

You can use any expression that Python3 allows inside f-string curly braces

A few examples to get you started:

  • name -- Filename without extension
  • ext -- File extension without leading dot
  • mime -- File mime type
  • stat information like
  • IDv3 tags like
  • file name parts if --regex is set:
    • regex[0] -- first match
    • regex[1] -- second match
    • and many more depending on your regex and number of matches

Examples

Dry move all files from folder test to test1 and rename them accordingly.

python3 metamove.py --type f --dry --name "test/**" "test1/{name}-{int(stat.st_mtime)}.{ext}"

Result:

test/file_example_MP3_1MG.mp3 -> test1/file_example_MP3_1MG-1640635451.mp3
test/test1.txt -> test1/test1-1640635453.txt
test/test2.dir -> test1/test2-1640635456.dir

Dry move mp3 files from folder test to test1, sort them by mp3.tag.artist into folders and use mp3.tag.title as filename.

python3 metamove.py --type f --dry --name "**/*.mp3" "test1/{mp3.tag.artist}/{mp3.tag.title}.{ext}"

Result:

test1/Kevin MacLeod/Impact Moderato.mp3">
./metamove.py --type f --dry --name "**/*.mp3" "test1/{mp3.tag.artist}/{mp3.tag.title}.{ext}"
test/file_example_MP3_1MG.mp3 -> test1/Kevin MacLeod/Impact Moderato.mp3

Dry move files from test to test1 and strip away the non-alphabetic characters from the filename.

python3 metamove.py --type f --dry --name "test/**" --regex "[A-Za-z]*" "test1/{regex[0]}.{ext}"

Result:

test/file_example_MP3_1MG.mp3 -> test1/file.mp3
test/test1.txt -> test1/test.txt
test/test2.dir -> test1/test.dir

What works

  • Globbing the files was kinda hard to figure out and may not be perfect.
  • Renaming mp3 files based on IDv3 meta data works.
  • Renaming other files based on stat meta data is also fine.
  • Using regex expressions to access parts of the filename.
  • Dry runs also work and are recommended before actually performing the action.

Wishlist

  • Plugins (e.g. exif, geographics, time formatting)

Try it out

Dependencies can be installed via

pip install -r requirements.txt

or

make init
Owner
Jan Philippi
I do things with computers and they do things with me.
Jan Philippi
Small Python script to generate a calendar (.ics) file from SIMASTER courses schedule.

simaster.ics Small Python script to generate a calendar (.ics) file from SIMASTER courses schedule. Usage Getting the events.json file from SIMASTER O

Faiz Jazadi 8 Nov 02, 2022
Python library and shell utilities to monitor filesystem events.

Watchdog Python API and shell utilities to monitor file system events. Works on 3.6+. If you want to use Python 2.6, you should stick with watchdog

Yesudeep Mangalapilly 5.6k Jan 04, 2023
organize - The file management automation tool

organize - The file management automation tool

Thomas Feldmann 1.5k Jan 01, 2023
Automatically generates a TypeQL script for doing entity and relationship insertions from a .csv file, so you don't have to mess with writing TypeQL.

Automatically generates a TypeQL script for doing entity and relationship insertions from a .csv file, so you don't have to mess with writing TypeQL.

3 Feb 09, 2022
Swiss army knife for Apple's .tbd file manipulation

Description Inspired by tbdswizzler, this simple python tool for manipulating Apple's .tbd format. Installation python3 -m pip install --user -U pytbd

10 Aug 31, 2022
This is a junk file creator tool which creates junk files in Internal Storage

This is a junk file creator tool which creates junk files in Internal Storage

KiLL3R_xRO 3 Jun 20, 2021
CSV To VCF (Multiples en un archivo)

CSV To VCF Convierte archivo CSV a Tarjeta VCF (varias en una) How to use En main.py debes reemplazar CONTACTOS.csv por tu archivo csv, y debes respet

Jorge Ivaldi 2 Jan 12, 2022
Simple, convenient and cross-platform file date changing library. 📝📅

Simple, convenient and cross-platform file date changing library.

kubinka0505 15 Dec 18, 2022
Python interface for reading and appending tar files

Python interface for reading and appending tar files, while keeping a fast index for finding and reading files in the archive. This interface has been

Lawrence Livermore National Laboratory 1 Nov 12, 2021
This simple python script pcopy reads a list of file names and copies them to a separate folder

pCopy This simple python script pcopy reads a list of file names and copies them to a separate folder. Pre-requisites Python 3 (ver. 3.6) How to use

Madhuranga Rathnayake 0 Sep 03, 2021
ZipFly is a zip archive generator based on zipfile.py

ZipFly is a zip archive generator based on zipfile.py. It was created by Buzon.io to generate very large ZIP archives for immediate sending out to clients, or for writing large ZIP archives without m

Buzon 506 Jan 04, 2023
pytiff is a lightweight library for reading chunks from a tiff file

pytiff is a lightweight library for reading chunks from a tiff file. While it supports other formats to some extend, it is focused on reading tiled greyscale/rgb images, that can also be bigtiffs. Wr

Big Data Analytics group 9 Mar 21, 2022
Simple Python File Manager

This script lets you automatically relocate files based on their extensions. Very useful from the downloads folder !

Aimé Risson 22 Dec 27, 2022
Import Python modules from any file system path

pathimp Import Python modules from any file system path. Installation pip3 install pathimp Usage import pathimp

Danijar Hafner 2 Nov 29, 2021
A simple library for temporary storage of small files

TemporaryStorage An simple library for temporary storage of small files. Navigation Install Usage In Python console As a standalone application List o

2 Apr 17, 2022
A file utility for accessing both local and remote files through a unified interface.

A file utility for accessing both local and remote files through a unified interface.

AI2 19 Nov 16, 2022
Python library for reading and writing tabular data via streams.

tabulator-py A library for reading and writing tabular data (csv/xls/json/etc). [Important Notice] We have released Frictionless Framework. This frame

Frictionless Data 231 Dec 09, 2022
An object-oriented approach to Python file/directory operations.

Unipath An object-oriented approach to file/directory operations Version: 1.1 Home page: https://github.com/mikeorr/Unipath Docs: https://github.com/m

Mike Orr 506 Dec 29, 2022
Convert CSV files into a SQLite database

csvs-to-sqlite Convert CSV files into a SQLite database. Browse and publish that SQLite database with Datasette. Basic usage: csvs-to-sqlite myfile.cs

Simon Willison 731 Dec 27, 2022
RMfuse provides access to your reMarkable Cloud files in the form of a FUSE filesystem

RMfuse provides access to your reMarkable Cloud files in the form of a FUSE filesystem. These files are exposed either in their original format, or as PDF files that contain your annotations. This le

Robert Schroll 82 Nov 24, 2022