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
CleverCSV is a Python package for handling messy CSV files.

CleverCSV is a Python package for handling messy CSV files. It provides a drop-in replacement for the builtin CSV module with improved dialect detection, and comes with a handy command line applicati

The Alan Turing Institute 1k Dec 19, 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
Pure Python tools for reading and writing all TIFF IFDs, sub-IFDs, and tags.

Tiff Tools Pure Python tools for reading and writing all TIFF IFDs, sub-IFDs, and tags. Developed by Kitware, Inc. with funding from The National Canc

Digital Slide Archive 32 Dec 14, 2022
A simple Python code that takes input from a csv file and makes it into a vcf file.

Contacts-Maker A simple Python code that takes input from a csv file and makes it into a vcf file. Imagine a college or a large community where each y

1 Feb 13, 2022
Test app for importing contact information in CSV files.

Contact Import TestApp Test app for importing contact information in CSV files. Explore the docs ยป ยท Report Bug ยท Request Feature Table of Contents Ab

1 Feb 06, 2022
Annotate your Python requirements.txt file with summaries of each package.

Summarize Requirements ๐Ÿ ๐Ÿ“œ Annotate your Python requirements.txt file with a short summary of each package. This tool: takes a Python requirements.t

Zeke Sikelianos 8 Apr 22, 2022
A tiny Configuration File Parser for Python Projects

A tiny Configuration File Parser for Python Projects. Currently working on JSON Config Files only.

Tanmoy Sen Gupta 1 Feb 12, 2022
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
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
Python file organizer application

Python file organizer application

Pak Maneth 1 Jun 21, 2022
MetaMove is written in Python3 and aims at easing batch renaming operations based on file meta data.

MetaMove MetaMove is written in Python3 and aims at easing batch renaming operations based on file meta data. MetaMove abuses eval combined with f-str

Jan Philippi 2 Dec 28, 2021
Here is some Python code that allows you to read in SVG files and approximate their paths using a Fourier series.

Here is some Python code that allows you to read in SVG files and approximate their paths using a Fourier series. The Fourier series can be animated and visualized, the function can be output as a tw

Alexander 12 Jan 01, 2023
A simple file sharing tool written in python

Share it A simple file sharing tool written in python Installation If you are using Windows os you can directly Run .exe file -- download If you are

Sachit Yadav 7 Dec 16, 2022
Maltego transforms to pivot between PE files based on their VirusTotal codeblocks

VirusTotal Codeblocks Maltego Transforms Introduction These Maltego transforms allow you to pivot between different PE files based on codeblocks they

Ariel Jungheit 18 Feb 03, 2022
OneDriveExplorer - A command line and GUI based application for reconstructing the folder strucure of OneDrive from the UserCid.dat file

OneDriveExplorer - A command line and GUI based application for reconstructing the folder strucure of OneDrive from the UserCid.dat file

Brian Maloney 100 Dec 13, 2022
A simple file module for creating, editing and saving files.

A simple file module for creating, editing and saving files.

1 Nov 25, 2021
Organizer is a python program that organizes your downloads folder

Organizer Organizer is a python program that organizes your downloads folder, it can run as a service and so will start along with the system, and the

Gustavo 2 Oct 18, 2021
Convert All TXT Files To One File.

AllToOne Convert All TXT Files To One File. Hi ๐Ÿ‘‹ , I'm Alireza A Python Developer Boy ๐Ÿ”ญ Iโ€™m currently working on my C# projects ๐ŸŒฑ Iโ€™m currently Lea

4 Jun 07, 2022
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
๐Ÿงน 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