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
You might also like...
gitfs is a FUSE file system that fully integrates with git - Version controlled file system

gitfs is a FUSE file system that fully integrates with git. You can mount a remote repository's branch locally, and any subsequent changes made to the files will be automatically committed to the remote.

This is a file deletion program that asks you for an extension of a file (.mp3, .pdf, .docx, etc.) to delete all of the files in a dir that have that extension.
This is a file deletion program that asks you for an extension of a file (.mp3, .pdf, .docx, etc.) to delete all of the files in a dir that have that extension.

FileBulk This is a file deletion program that asks you for an extension of a file (.mp3, .pdf, .docx, etc.) to delete all of the files in a dir that h

Small-File-Explorer - I coded a small file explorer with several options
Small-File-Explorer - I coded a small file explorer with several options

Petit explorateur de fichier / Small file explorer Pour la première option (création de répertoire) / For the first option (creation of a directory) e

Pti-file-format - Reverse engineering the Polyend Tracker instrument file format

pti-file-format Reverse engineering the Polyend Tracker instrument file format.

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.

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.

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

Extract longest transcript or longest CDS transcript from GTF annotation file or gencode transcripts fasta file.

Extract longest transcript or longest CDS transcript from GTF annotation file or gencode transcripts fasta file.

Two scripts help you to convert csv file to md file by template

Two scripts help you to convert csv file to md file by template. One help you generate multiple md files with different filenames from the first colume of csv file. Another can generate one md file with several blocks.

A simple file sharing tool written in python
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

Owner
Jan Philippi
I do things with computers and they do things with me.
Jan Philippi
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
Extract an archive file (zip file or tar file) stored on AWS S3

S3 Extract Extract an archive file (zip file or tar file) stored on AWS S3. Details Downloads archive from S3 into memory, then extract and re-upload

Evan 1 Dec 14, 2021
File-manager - A basic file manager, written in Python

File Manager A basic file manager, written in Python. Installation Install Pytho

Samuel Ko 1 Feb 5, 2022
Search for files under the specified directory. Extract the file name and file path and import them as data.

Search for files under the specified directory. Extract the file name and file path and import them as data. Based on that, search for the file, select it and open it.

G-jon FujiYama 2 Jan 10, 2022
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
Python package to read and display segregated file names present in a directory based on type of the file

tpyfilestructure Python package to read and display segregated file names present in a directory based on type of the file. Installation You can insta

Tharun Kumar T 2 Nov 28, 2021
A tool for batch processing large fasta files and accompanying metadata table to upload to repositories via API

Fasta Uploader A tool for batch processing large fasta files and accompanying metadata table to repositories via API The python fasta_uploader.py scri

Centre for Infectious Disease and One Health 1 Dec 9, 2021
A python script to convert an ucompressed Gnucash XML file to a text file for Ledger and hledger.

README 1 gnucash2ledger gnucash2ledger is a Python script based on the Github Gist by nonducor (nonducor/gcash2ledger.py). This Python script will tak

Thomas Freeman 0 Jan 28, 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

null 1 Feb 13, 2022
QSynthesis is a Python3 API to perform I/O based program synthesis of bitvector expressions.

QSynthesis is a Python3 API to perform I/O based program synthesis of bitvector expressions. It aims at facilitating code deobfuscation. The algorithm is greybox approach combining both a blackbox I/O based synthesis and a whitebox AST search to synthesize sub-expressions

Quarkslab 103 Dec 30, 2022