Rename photos and videos based on EXIF capture timestamp.
Pix is a command-line tool that renames photo and video files based on their EXIF metadata, specifically the capture timestamp. It supports custom formatting and recursive directory traversal. This utility is helpful for organizing media files chronologically.
- Rename files using the EXIF
DateTimeOriginalandSubSecTimeOriginaltags. - Customizable filename formats using
strftime-compatible format specifiers (see strftime.org). - Preset formats for common naming conventions.
- Recursive directory processing.
- Simulate mode to preview changes without modifying files.
Usage: pix [OPTIONS] FILE | DIRECTORY
Rename photos and videos based on EXIF capture timestamp.
Options:
-p, --preset <NUMBER> Use predefined format preset (default is 0):
0: %Y%m%d%H%M%S%f
1: %Y%m%d_%H%M%S_%f
2: %Y%m%d-%H%M%S-%f
3: %Y-%m-%d_%H-%M-%S_%f
4: %Y_%m_%d-%H_%M_%S-%f
-f, --format <FORMAT> Use custom format (strftime-compatible; overrides preset)
-s, --simulate Perform a dry run (do not rename files)
-r, --recursive Recursively process directories
-v, --version Show program version
-h, --help Show this help message
A target FILE or DIRECTORY must be specified.
If a FILE is specified, only that file will be processed.
If a DIRECTORY is specified, files in that directory will be processed.
Use '.' to specify the current directory.
pix photo.jpgRenames photo.jpg using the default preset format.
pix /path/to/directoryProcesses all supported files in /path/to/directory.
pix -r /path/to/directoryProcesses all supported files in /path/to/directory and its subdirectories.
pix -f "%Y_%m_%d__%H%M%S" photo.jpgRenames photo.jpg using the custom format.
pix -s -r /path/to/directoryPerforms a dry run and displays the intended renaming actions without modifying any files.
pix .Processes all supported files in the current directory (non-recursive).
pix -r .Processes all supported files in the current directory and subdirectories.
Pix uses CMake for its build system.
- C Compiler: Ensure you have a C compiler that supports C17 (e.g.,
gcc,clang). - CMake: Version 3.10 or higher.
- libexif: Install the development files for
libexif.
sudo apt-get update
sudo apt-get install build-essential cmake libexif-dev-
Clone the Repository
git clone https://github.com/heldercorreia/pix.git cd pix -
Create a Build Directory
mkdir build cd build -
Run CMake and Build
cmake .. make
-
Install (Optional)
sudo make install
This will install the
pixexecutable to/usr/local/bin.
Pix recognizes the following image and video file extensions:
- Images:
.jpg,.jpeg,.png,.gif,.bmp,.tif,.tiff,.heic,.heif,.webp - Videos:
.mp4,.mov,.avi,.mkv
Pix uses strftime-compatible format specifiers with an additional %f for microseconds extracted from SubSecTimeOriginal.
- Example Format:
%Y%m%d%H%M%S%f - Microseconds Handling:
- If
SubSecTimeOriginalexists:- Value is adjusted to always be 6 digits.
- Padded with zeros on the right if less than 6 digits.
- Truncated to 6 digits if more.
- If it doesn't exist:
- Defaults to
000000.
- Defaults to
- If
Contributions are welcome! Please open an issue or submit a pull request on GitHub.
This project is licensed under the MIT License.
- Error Handling: Always ensure you have backups of your files before running batch operations that modify or rename files.
- Extending File Extensions: To handle additional file types, modify the
extensionsarray in theis_image_or_videofunction.