Skip to content

mountlord/TransNamer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TransNamer

A command-line tool to translate filenames from one language to another using Google Translate.

Features

  • Translates filenames (preserving extensions)
  • Renames directories too
  • Recursive processing of subdirectories
  • Auto-detects source language if not specified
  • Dry-run mode to preview changes
  • Handles filename conflicts with -1, -2, -3 suffixes
  • Sanitizes invalid filename characters

Installation

From Source

pip install -r requirements.txt
python transnamer.py --help

Build Executable (Windows)

build.bat

This creates TransNamer.exe in the dist folder.

Usage

TransNamer --input <directory> [--from <lang>] [--to <lang>] [--dry-run]

Arguments

Argument Short Required Default Description
--input -i Yes - Input directory to process
--from -f No auto Source language code (e.g., ja, zh, ko)
--to -t No en Target language code
--dry-run -d No - Preview translations without renaming
--workers -w No 10 Number of concurrent translation workers

Language Codes

Common language codes:

  • en - English
  • ja - Japanese
  • zh - Chinese (Simplified)
  • zh-TW - Chinese (Traditional)
  • ko - Korean
  • es - Spanish
  • fr - French
  • de - German
  • ru - Russian

For a full list, see Google Translate language codes.

Examples

Translate Japanese filenames to English (dry run)

TransNamer --input ./anime_folder --from ja --to en --dry-run

Translate with auto-detection

TransNamer --input ./mixed_files --to en

Translate Chinese to Spanish

TransNamer --input ./documents --from zh --to es

Notes

  • Files and directories are processed recursively
  • Directories are renamed after files (deepest directories first) to avoid path issues
  • If a translated filename already exists, a numeric suffix is added (-1, -2, etc.)
  • Invalid filename characters are replaced with underscores
  • The original file extension is always preserved

Performance

  • Translation uses concurrent requests (10 workers by default)
  • Duplicate names are translated only once
  • ASCII-only filenames are automatically skipped
  • Use --workers to tune concurrency (lower if rate-limited, higher for speed)

Requirements

  • Python 3.10+
  • Internet connection (for Google Translate API)

About

Renames your files in one language to another.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors