AlgoRename
Table of Contents
- Introduction
- Prerequisites
- Installation
- Usage
- Algorithm Loading
- Algorithm Listing
- Multiprocessing
- Logging
- License
Introduction
This utility is a Python script designed to rename files in a folder or an individual file based on a dynamically loaded algorithm. It utilizes multiprocessing for efficiency and can operate recursively on directories. The example algorithm shifts each alphabetic character in the filenames to the left by 1.
Prerequisites
- Python 3.6+
Installation
- Clone the GitHub repository.
git clone https://github.com/darkarp/algorename.git - Navigate to the project directory.
cd algorename - Install the required Python packages.
pip install -r requirements.txt
Usage
Command Line Arguments
- To rename a single file:
python algorename.py -f [path/to/your/file]
- To rename all files in a directory:
python algorename.py -d [path/to/your/directory]
- To rename files recursively in a directory:
python algorename.py -d [path/to/your/directory] -r
- For silent mode (suppress errors):
python algorename.py -s (...)
- To not create a log file:
python algorename.py -nl (...)
- To use a specific algorithm:
python algorename.py -a [algorithm_name]
- To list available algorithms:
python algorename.py -l
- For help:
python algorename.py -h
Algorithm Loading
The script supports loading custom algorithms. Place your algorithm module under the algorithms/ folder, and the script will be able to import it dynamically. Make sure to define a function called apply_algorithm within the module.
The environment variable FCLOG_PATH specifies the directories where the script will look for custom algorithm modules. You can modify this by changing your environment variables or by creating a .env file.
Example:
- Windows:
FCLOG_PATH=C:\path\to\algorithms;D:\another\path\to\algorithms - Linux/Mac:
FCLOG_PATH=/path/to/algorithms:/another/path/to/algorithms
Algorithm Listing
You can list all available algorithms along with their metadata using the -l flag. This is useful for understanding what each algorithm does before using it.
Multiprocessing
This utility uses multithreading to efficiently rename multiple files in a directory. It uses concurrent.futures.ThreadPoolExecutor to speed up the renaming tasks.
Logging
Logging is implemented with a rotating log file mechanism to ensure that it doesn't consume too much disk space over time. The log file will be generated in the same directory as the script, named algorename.log.
- You can set the logging verbosity level via an environment variable
FCLOG_LEVEL, which accepts values likeDEBUG,INFO,WARNING,ERROR, andCRITICAL. - You can set the log file name via an environment variable
FCLOG_NAME. This name will be converted to lower-case. - You can disable logging by specifying
-nlargument.
License
This project is licensed under the MIT License - see the LICENSE.md file for details.
Metadata
Release files for algorename 1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| algorename-1.6.tar.gz | 7.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| algorename-1.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.0 kB
Release files / algorename-1.6.tar.gz
| Download URL | algorename-1.6.tar.gz |
|---|---|
| Size | 7.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2ea29a501f1d84accfd37be9e63faaf6aa2094e4ab6559d65983dc720f77ae8a
|
|
BLAKE2b-256 checksum How to use checksums |
4ccaadac426bedcfa0218152b85f8ca98cc913eeb6ff24d05c4746ff1b67c202
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.1
|
Release files / algorename-1.6-py3-none-any.whl
| Download URL | algorename-1.6-py3-none-any.whl |
|---|---|
| Size | 9.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0e596e915823e23efdcc64a52ce47cd14fe75428ed81c4642b7057defbf2a0ea
|
|
BLAKE2b-256 checksum How to use checksums |
2d000c2a36bac2e2367e1682c0aa1533a243d6f2bae315eb0fb5c246a9329291
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.1
|