Skip to content

ss8931/file-renamer

Repository files navigation

File Renamer

MIT. See LICENSE.

An LLM-based file renamer.

Motivation

I organize my files in a tree structure. So the filename itself actually needs to be short. The multiple directories and subdirectories provide the context.

For example, a file named slide-week-01' would be in a directory: fall/COMP-XX/slides/`. The filename might have redundant information, like the course name, or the semester.

The problem I run into is I often download files which have long names. I want to rename them to something short and meaningful. I want to do this quickly, without having to think too much about it.

LLM makes this possible.

Set up

Prereq. Dotnet.

Create an .env file anywhere.

Apply for a key, if you don't have one already Google Makersuite

API_KEY=YOUR_KEY
PROMPT_FILE=REAL_PATH_TO_PROMPT_FILE

PROMPT_FILE already exists, see prompts/prompt-00. Of course, you can create your own.

If you'd like to add it to your path to run it from anywhere, just symlink it to your home bin or usr bin.

ln -s /path/to/repo/bin/Release/net7.0/file-renamer file-renamer ~/bin/file-renamer

Usage

Training

Train the model a new mapping.

dotnet run -- add original_name new_name

Renaming

Will rename the files. If there are conflicts in the generated names, or new file conflicts with an existing one, will fail.

dotnet run -- rename [files]

Run it in dry-run mode to see what it would do.

dotnet run -- rename --dry-run [files]

Or, add verbosity

dotnet run -- rename --verbose [files]

Or, hide files which are already named well.

dotnet run -- rename --hide-no-changes [files]

Or, train it. Training implies dry-run.

dotnet run -- rename --train [files]

Releases

No releases published

Packages

No packages published

Languages