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
Lumar - Smart File Creator

Lumar is a free tool for creating and managing files. With Lumar you can quickly create any type of file, add a file content and file size. With Lumar you can also find out if Photoshop or other imag

Paul - FloatDesign 3 Dec 10, 2021
CSV-Handler written in Python3

CSVHandler This code allows you to work intelligently with CSV files. A file in CSV syntax is converted into several lists, which are combined in a to

Max Tischberger 1 Jan 13, 2022
Uproot is a library for reading and writing ROOT files in pure Python and NumPy.

Uproot is a library for reading and writing ROOT files in pure Python and NumPy. Unlike the standard C++ ROOT implementation, Uproot is only an I/O li

Scikit-HEP Project 164 Dec 31, 2022
Python function to stream unzip all the files in a ZIP archive: without loading the entire ZIP file or any of its files into memory at once

Python function to stream unzip all the files in a ZIP archive: without loading the entire ZIP file or any of its files into memory at once

Department for International Trade 206 Jan 02, 2023
Python script for converting figma produced SVG files into C++ JUCE framework source code

AutoJucer Python script for converting figma produced SVG files into C++ JUCE framework source code Watch the tutorial here! Getting Started Make some

SuperConductor 1 Nov 26, 2021
Python's Filesystem abstraction layer

PyFilesystem2 Python's Filesystem abstraction layer. Documentation Wiki API Documentation GitHub Repository Blog Introduction Think of PyFilesystem's

pyFilesystem 1.8k Jan 02, 2023
Organize the files into the relevant sub-folders

This program can be used to organize files in a directory by their file extension. And move duplicate files to a duplicates folder.

Thushara Thiwanka 2 Dec 15, 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
Python Sreamlit Duplicate Records Finder Remover

Python-Sreamlit-Duplicate-Records-Finder-Remover Streamlit is an open-source Python library that makes it easy to create and share beautiful, custom w

RONALD KANYEPI 1 Jan 21, 2022
Generates a clean .txt file of contents of a 3 lined csv file

Generates a clean .txt file of contents of a 3 lined csv file. File contents is the .gml file of some function which stores the contents of the csv as a map.

Alex Eckardt 1 Jan 09, 2022
Add Ranges and page numbers to IIIF Manifest from a CSV.

Add Ranges and page numbers to IIIF Manifest from CSV specific to a workflow of the Bibliotheca Hertziana.

Raffaele Viglianti 3 Apr 28, 2022
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
PaddingZip - a tool that you can craft a zip file that contains the padding characters between the file content.

PaddingZip - a tool that you can craft a zip file that contains the padding characters between the file content.

phithon 53 Nov 07, 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
Some-tasks - Files for some of the tasks for the group sessions

Files for some of the tasks for the group sessions Here you can find some of the

<a href=[email protected] Computer Networks"> 0 Aug 25, 2022
ValveVMF - A python library to parse Valve's VMF files

ValveVMF ValveVMF is a Python library for parsing .vmf files for the Source Engi

pySourceSDK 2 Jan 02, 2022
🧹 Create symlinks for .m2ts files and classify them into directories in yyyy-mm format.

🧹 Create symlinks for .m2ts files and classify them into directories in yyyy-mm format.

Nep 2 Feb 07, 2022
OnedataFS is a PyFilesystem interface to Onedata virtual file system

OnedataFS OnedataFS is a PyFilesystem interface to Onedata virtual file system. As a PyFilesystem concrete class, OnedataFS allows you to work with On

onedata 0 Jan 10, 2022
Yadl - it is a simple library for working with both dotenv files and environment variables.

Yadl Yadl - it is a simple library for working with both dotenv files and environment variables. Features Validation of whitespaces. Validation of num

Ivan Kapranov 3 Oct 19, 2021
Python virtual filesystem for SQLite to read from and write to S3

Python virtual filesystem for SQLite to read from and write to S3

Department for International Trade 70 Jan 04, 2023