Skip to content

cadentdev/iname

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

iname — Internet Name

CI PyPI Python License: MIT

Make filenames safe and consistent for the web. One file at a time, composable with Unix pipes.

Install

pip install iname

Usage

# Rename a single file (default: web style with hyphens)
iname "My Photo (2).jpeg"           # → my-photo-2.jpeg

# Preview without renaming
iname "My Photo (2).jpeg" --dry-run

# Different naming styles
iname "My Photo.jpeg" --style snake  # → my_photo.jpeg
iname "My Photo.jpeg" --style kebab  # → my-photo.jpeg
iname "My Photo.jpeg" --style camel  # → myPhoto.jpeg

# Batch rename with find
find . -name "*.jpeg" | iname

# Chain with other tools
iname "My Photo.jpeg" | xargs ls -la

# Preview a batch
find . -name "*.JPEG" | iname --dry-run --verbose

Styles

Style Input Output
web (default) My Photo (2).jpeg my-photo-2.jpeg
snake My Photo (2).jpeg my_photo_2.jpeg
kebab My_Photo (2).jpeg my-photo-2.jpeg
camel My Photo (2).jpeg myPhoto2.jpeg

Behavior

  • Stdout: always prints the new path (enables piping and chaining)
  • Stderr: --verbose prints old → new mappings (doesn't interfere with pipes)
  • Collisions: auto-dedup with -01, -02, ... -99 suffix
  • Already safe: prints path unchanged, exits 0
  • Exit codes: 0 = success, 1 = error, 2 = usage error

Safety

  • Rejects symlinks
  • Strips null bytes
  • Normalizes Unicode whitespace (no-break spaces, narrow spaces)
  • Truncates to filesystem NAME_MAX (255 bytes)
  • Case-insensitive filesystem aware

Zero dependencies

iname uses only the Python standard library. No runtime dependencies.

Development

pip install -e '.[dev]'
pytest --cov=iname --cov-report=term-missing

Origin

Extracted from xplat — the proven rename logic, distilled into a single-purpose Unix tool.

About

Internet Name — make filenames safe and consistent for the web

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages