Skip to content

A tool to rename photos and videos to a consistent, helpful format

License

Notifications You must be signed in to change notification settings

DCWelch/file_renamer

Repository files navigation

This File Renamer is a tool designed for Windows to rename a collection of vacation photos from various sources in a very simple, consistent, and specific way. The new naming format is primarily based on the date taken, when available, and can be represented as follows:

<year>_<month>_<day>_<hour>_<id>

Examples:

20230228_092122(0).png  -->  2023_02_28_09_001.png
Snapchat-286861347.jpg  -->  2023_03_02_17_002.jpg
Screenshot_20240620_124449_Chrome.jpg  -->  2024_06_20_12_003.jpg
0 Travel Day (3aaa).heic  -->  2024_06_20_17_004.heic
0 Travel Day (4).mp4  -->  2024_06_20_17_005.mp4

This tool was created for a very specific use case, so it is intentionally static and simple. Visit dcwelch.github.io/file_renamer for more high-level information.

example_file_renamer_gui

Features

  • Renames files using date taken-equivelant metadata (e.g., DateTimeOriginal for images)
  • Handles missing metadata gracefully with fallback timestamps (typically using last modified date)
    • Designates these files in a separate, reviewable category prefixed with "ZZZ_"
  • Support for a majority of common image and videos file formats, including...
    • .png/.jpg/.jpeg image files via pillow
    • .heic image files via pillow-heif
    • .mp4/.mov video files via ffprobe
    • no other file formats are currently tested, but most others should process normally using the fallback date at a minimum
  • Logs operations which maintain name mapping to...
    1. A live GUI log window
    2. A log file in the selected directory and a dedicated logs directory
  • Intuitive GUI built with Tkinter
  • Built for Windows

Alternatives

Many similar tasks may find themselves better solved with one of these tools:

Download the latest version of the tool

Visit dcwelch.github.io/file_renamer or the repo's Releases tab to download the executable and necessary supporting files, which are packaged together in a zip file called rename_files_executable.zip.

Build the project from source

Prerequisites

  • Python 3.12 or later
  • The following Python dependencies (included in requirements.txt):
    pillow
    pillow-heif
    pytz
    piexif
    
  • FFmpeg for ffprobe support (ensure it’s in your system PATH)
  • pyinstaller (only if a new executable is desired)

Steps

  1. Clone the repository:
    git clone https://github.com/DCWelch/file_renamer.git
    cd file_renamer
  2. Install dependencies:
    pip install -r requirements.txt
  3. Run the script:
    python rename_files.py

Build an Executable

To create a standalone executable:

  1. Install pyinstaller:
    pip install pyinstaller
  2. Use the following commands to generate the executable:
    $piexif_path = python -c "import piexif; import os; print(os.path.dirname(piexif.__file__))"
    pyinstaller --clean --noconfirm --noconsole --icon=file_renamer_icon.ico --add-data "file_renamer_icon.ico;." --add-data "$piexif_path;piexif" --hidden-import=pillow_heif --hidden-import=pytz.zoneinfo --hidden-import=piexif --collect-all pillow_heif --collect-all piexif --exclude-module numpy --exclude-module mkl --exclude-module tcl --exclude-module tbb --exclude-module pywin32 --exclude-module psutil --log-level=DEBUG rename_files.py
  3. The executable will be located in the dist/ folder

Usage

  1. Launch the application (via rename_files.exe)
  2. Use the Pick Folder button to select a target directory
  3. Click Start Renaming to rename all files in the selected directory

Directory Structure

file_renamer/
├── rename_files.py  # Main script
├── requirements.txt  # Dependencies
├── file_renamer_icon.ico  # App icon
├── .gitignore  # Specifies intentionally untracked files to ignore
├── LICENSE  # License
├── README.md  # Documentation
├── .github/  # Outlines GitHub Actions workflow for the build
│   └──
├── dist/  # Contains built executable (after running PyInstaller)
│   └── rename_files/
│       ├── rename_files.exe  # Executable file to launch the file_renamer GUI
│       └── _internal/  # Contains necessary dependencies for the executable
│           ├── logs/  # Stores log files (created at runtime)
│           │   └──
│           └──
└── build/  # Contains build artifacts (after running PyInstaller)
    └── 

Contributing and Feedback

Contributions and feedback are always welcome! Here's how you can get involved:

Reporting Issues or Requesting Features

If you encounter a bug or have ideas for new features, please use the GitHub Issues page to...

  • Report Bugs: Provide a clear description, steps to reproduce, and any relevant logs or screenshots
  • Request Features: Share your suggestions for new features or improvements

Submitting Code Contributions

If you'd like to contribute code changes...

  1. Fork the repository
  2. Create a new branch for your feature or bug fix
  3. Submit a pull request with a detailed description of your proposed changes

Any feedback, suggestions, or contributions are greatly appreciated!

License

This project is licensed under the MIT License

Acknowledgments

  • Pillow: For image processing and EXIF metadata handling
  • pillow-heif: For HEIC/HEIF image support
  • pytz: For timezone handling
  • FFmpeg: For video metadata extraction via ffprobe
  • Tkinter: For the GUI resources
  • Flaticon: Folder icons created by Freepik
  • The Python community: For providing the libraries and tools that power this application

Contact

For questions, feedback, or support, feel free to contact me at [email protected]

About

A tool to rename photos and videos to a consistent, helpful format

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages