Skip to main content

Harmonize file and directory names for Linux, Windows and macOS.

Project description

CrossRename Logo

Harmonize file and directory names for Linux, Windows, and macOS.

Explore the repo »

Table of Contents

Introduction

CrossRename is a command-line tool designed to harmonize file and directory names across Linux, Windows, and macOS systems. It ensures that your file names are compatible with all three operating systems, eliminating naming conflicts when transferring files between different environments.

Features

  • Sanitizes file names to be Windows-compatible (and thus Linux-compatible and macOS-compatible)

  • Byte-aware filename truncation (correctly handles CJK, Cyrillic, emoji, and other multi-byte UTF-8 characters)

  • Option to replace forbidden characters with Unicode lookalikes instead of removing them

  • Optionally renames directories to be cross-platform compatible

  • Handles both individual files and entire directories

  • Supports recursive renaming of files in subdirectories

  • Preserves file extensions, including compound extensions like .tar.gz

  • Provides informative logging

  • Provides a dry-run mode to preview renaming changes without executing them

  • Interactive safety warnings with option to skip for automation

  • Skips recursive symlinks to avoid infinite loops

back to introduction

Installation

From PyPI (Using PIP)

pip install CrossRename

back to introduction

Usage

usage: crossrename [-h] [-p PATH] [-v] [-u] [-r] [-d] [-D] [-a] [--force] [--max-filename-bytes N] [--credits]

CrossRename: Harmonize file and directory names for Linux, Windows and macOS.

options:
  -h, --help                  show this help message and exit
  -p, --path PATH             The path to the file or directory to rename.
  -v, --version               Prints out the current version and quits.
  -u, --update                Check if a new version is available.
  -r, --recursive             Rename all files in the directory path given and its subdirectories. When used with -D, also renames subdirectories.
  -d, --dry-run               Perform a dry run, logging changes without renaming.
  -D, --rename-directories    Also rename directories to be cross-platform compatible. Use with caution!
  -a, --use-alternatives      Replace forbidden characters with Unicode lookalikes instead of removing them. May cause display issues on some systems.
  --force                     Skip safety prompts (useful for automated scripts)
  --max-filename-bytes N      Maximum filename length in bytes (default: 255, valid range: 4-255).
  --credits                   Show credits and support information

back to introduction

Examples

Rename a single file:

crossrename -p /path/to/file.txt

Rename all files in a directory (and its subdirectories):

crossrename -p /path/to/directory -r

Rename all files AND directories recursively:

crossrename -p /path/to/directory -r -D

Rename a single directory:

crossrename -p /path/to/problematic_directory -D

Perform a dry run to preview renaming changes without executing them:

crossrename -p /path/to/directory -r -D -d

Skip safety prompts for automated scripts:

crossrename -p /path/to/directory -r -D --force

Use Unicode alternatives instead of removing characters:

crossrename -p /path/to/file.txt -a

Check for an update:

crossrename -u

Show credits and project information:

crossrename --credits

Limit filename length for Linux filesystems (useful for CJK or emoji-heavy filenames):

crossrename -p /path/to/directory -r --max-filename-bytes 255

back to introduction

Unicode Alternatives Mode

Use –use-alternatives to replace forbidden characters with similar Unicode characters instead of removing them:

crossrename -p "file<name>.txt" --use-alternatives
 # Result: "fileᐸnameᐳ.txt" instead of "filename.txt"

Character mappings:

  • < (Canadian Syllabics Pa)

  • > (Canadian Syllabics Po)

  • : (Ratio)

  • "ʺ (Modified Letter Double Prime)

  • / (Division Slash)

  • \ (Reverse Solidus Operator)

  • | (Divides)

  • ? (Small Question Mark)

  • *🞱 (Bold Five Spoked Asterisk)

back to introduction

Safety First

CrossRename will show interactive safety warnings before making any changes to help prevent accidental data loss. However, it’s strongly recommended to:

  1. Run a dry run first to preview what will be changed:

    crossrename -p /your/path -r -D -d
  2. Backup your data before running the tool on important files

  3. Use --force flag for automation in CI/CD pipelines:

    crossrename -p /your/path -r -D --force

Directory renaming is particularly powerful and potentially disruptive since it changes folder paths that other applications might reference.

back to introduction

Platform Compatibility

CrossRename works on:

  • Windows

  • Linux

  • macOS

The tool sanitizes filenames to be compatible with the most restrictive filesystem (Windows), ensuring files work everywhere. This means:

  • Removing Windows-forbidden characters: < > : " / \ | ? *

  • Handling Windows reserved names: CON, PRN, AUX, NUL, COM1-9, LPT1-9

  • Removing trailing spaces and periods

  • Removing control characters

  • Limiting filenames to 255 bytes (for ext4/btrfs compatibility; configurable via --max-filename-bytes)

Since Windows has the strictest rules, files renamed by CrossRename will work on Linux and macOS without issues.

back to introduction

Why did I build this?

So I was dual-booting Windows 10 and Lubuntu 22.04, and one day I’m trying to move some files between the two systems. Five files just wouldn’t copy over because of what I later found out were the differences in Windows and Linux’s file naming rules.

That got me thinking because I’d already built a Python package that had to deal with some file creation and renaming ( It’s called FicImage, please check it out 🫶) before, so I had an idea or two about how to go about this.

Long story short, I got annoyed enough to build CrossRename. Now I don’t have to deal with file naming headaches when switching between systems.

back to introduction

Contributing

Contributions are welcome! If you’d like to improve CrossRename please feel free to submit a pull request.

Especially welcome:

  • macOS/APFS testing and feedback (currently untested on real macOS hardware)

  • Linux testing and feedback (on native linux)

  • Edge case handling for Unicode normalization differences

  • Performance improvements for large directory trees

  • Other Operating Systems

  • Any other thing I forgot to list here

back to introduction

Wait a minute, who are you?

Hello there! I’m Emmanuel Jemeni, and while I primarily work as a Frontend Developer, Python holds a special place as my first programming language. You can find me on various platforms:

back to introduction

License

MIT License

back to introduction

Changelog

Changelog

back to introduction

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

crossrename-1.5.0.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

crossrename-1.5.0-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

Details for the file crossrename-1.5.0.tar.gz.

File metadata

  • Download URL: crossrename-1.5.0.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for crossrename-1.5.0.tar.gz
Algorithm Hash digest
SHA256 51e049def5f6ca69c9a694f52b39de747abaae9b703e4c515648d654a46e259b
MD5 937558b01a003d31c31bb19fa3d1f301
BLAKE2b-256 024dda8354937011610fcd2c13a738d5620974cf97ace59280f84d167563edde

See more details on using hashes here.

File details

Details for the file crossrename-1.5.0-py3-none-any.whl.

File metadata

  • Download URL: crossrename-1.5.0-py3-none-any.whl
  • Upload date:
  • Size: 12.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for crossrename-1.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 995aa30da198cca55c21991dd6436eeaba449b9f7e0d9b81c72ec82c093c4dd7
MD5 b4837595fdf0180c0481aae12865e9ac
BLAKE2b-256 44ea5a7550eef7e98e0755d2a7cddf70ef600477c5d31fd24ea85eea7860e5ed

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page