Skip to content

A Python script that recursively normalizes file and directory names to a consistent format. It converts names to lowercase, replaces spaces with underscores, and removes special characters.

License

Notifications You must be signed in to change notification settings

Lorry127/file-name-normalizer

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

File and Directory Name Normalizer

A Python script that recursively normalizes file and directory names to a consistent format. It converts names to lowercase, replaces spaces with underscores, and removes special characters.

Features

  • Recursively processes both files and directories
  • Converts all names to lowercase
  • Replaces spaces with underscores
  • Removes duplicate underscores
  • Removes special characters (keeps alphanumeric and underscores)
  • Specifically handles .png files
  • Prints operation logs during execution
  • Safe directory traversal (processes bottom-up)
  • Error handling for rename operations

Prerequisites

  • Python 3.x
  • No additional packages required (uses only standard library)

Installation

  1. Clone this repository:
git clone https://github.com/lorenz-127/file-name-normalizer.git
cd file-name-normalizer
  1. No additional installation required!

Usage

  1. Run the script:
python rename_script.py
  1. Enter the directory path when prompted:
Enter the directory path to process: /path/to/your/directory

Example Transformations

Files:

  • Egg_Sprite.pngegg_sprite.png
  • Game Character.pnggame_character.png
  • PLAYER__ANIMATION.pngplayer_animation.png

Directories:

  • Game Assetsgame_assets
  • Character_Spritescharacter_sprites
  • BACKGROUND__FILESbackground_files

Safety Features

  • The script processes directories bottom-up to handle nested directories correctly
  • Error handling prevents script crashes on permission issues or invalid operations
  • All operations are logged to console for tracking

Important Notes

  • Always backup your files before running this script!
  • The script only processes .png files, but can be modified for other extensions
  • Directory names at all levels will be renamed
  • Special characters are removed from names
  • File extensions are preserved but converted to lowercase

Contributing

Feel free to open issues or submit pull requests with improvements.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

Lorenz-127

About

A Python script that recursively normalizes file and directory names to a consistent format. It converts names to lowercase, replaces spaces with underscores, and removes special characters.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%