README
¶
EXIF Commit
A command-line tool to update the ImageDescription EXIF tag in image files using a commit-message style workflow.
Description
exifcommit simplifies the process of batch updating the ImageDescription EXIF tag in image files. It provides a commit-message-like interface, allowing you to specify a new description in your preferred text editor and apply it to multiple image files at once.
Key Features:
- Batch Tagging: Apply the same
ImageDescriptionto multiple image files. - Editor-Based Workflow: Uses your favorite text editor to write the new description, offering flexibility and familiar editing features.
- File Selection by Search Term: Finds target image files based on a search term in their filenames.
- Preview of Current Tags: Displays the current
ImageDescriptionfor each found file in the commit file, allowing you to verify targets before applying changes. - Dry-Run (Implicit): By simply not saving the commit file in the editor, you can effectively perform a dry-run, reviewing the files that would be modified without making any changes.
- Uses
exiftool: Leverages the powerfulexiftoolcommand-line utility for efficient EXIF metadata manipulation.
Installation
Prerequisites
- Go: You need Go installed on your system. You can download it from https://go.dev/dl/. Ensure your Go environment is properly set up, including
$GOPATHor$GOBINbeing in your$PATH. - exiftool:
exifcommitrelies on theexiftoolcommand-line utility. You need to installexiftoolseparately as it's not included with this Go program. Instructions for installingexiftoolcan be found on the official website: https://exiftool.org/install.html. Make sureexiftoolis in your system's$PATHso thatexifcommitcan execute it.
Installing exifcommit
-
Clone the repository (if you have the source code):
git clone <repository_url> cd exifcommit -
Install using
go install:go install github.com/davenuman/exifcommit/exifcommit@latestThis command will download and build
exifcommit, placing the executable in your$GOPATH/binor$GOBINdirectory. Ensure this directory is in your system's$PATHso you can runexifcommitfrom anywhere in the terminal.
Usage
Basic Usage
exifcommit <search_term>
Replace <search_term> with a term to search for in filenames. exifcommit will search for files in the current directory and any directories specified in the EXIFCOMMIT_PATH environment variable (see below). Filenames containing the <search_term> will be considered for EXIF tag modification.
Example:
To update the ImageDescription tag for all files with 123 in the filename in the current directory and its subdirectories, you could use:
exifcommit 123
Workflow
- File Search:
exifcommitsearches for files matching the<search_term>in the current directory and any paths defined by theEXIFCOMMIT_PATHenvironment variable. - Temporary Commit File: A temporary file (starting with
.EXIF-and located in the current directory) is created. This file is opened in your default text editor (or the editor specified by theEDITORenvironment variable). - Edit the Commit File:
- First Line: The first line of the file is designated as the new
ImageDescriptionthat will be applied to the selected image files. - Empty Description: If you leave the first line empty or delete its content,
exifcommitwill abort and no changes will be made. - File List: The file contains a list of the files found, each preceded by
# file: <filepath>. Below each file path, the currentImageDescriptiontag (if it exists) is displayed. Lines starting with#are treated as comments and are ignored during parsing, except for the# file:lines which identify the target file paths. - Modify Files: To apply the new
ImageDescriptionto a file, ensure the line starting with# file: ...for that file remains in the file and is not commented out. - Exclude Files: To exclude a file from being modified, you can delete the entire line starting with
# file: ....
- First Line: The first line of the file is designated as the new
- Save and Close Editor: Save the changes in your text editor and close the editor.
- Apply Changes:
exifcommitparses the temporary file. If a new description is provided and file lines are present, it usesexiftoolto update theImageDescriptiontag for the listed files using the provided description. - Cleanup: The temporary commit file is automatically deleted after processing.
Environment Variables
-
EXIFCOMMIT_PATH: This environment variable allows you to extend the directoriesexifcommitsearches in. It uses the system's path list separator (e.g.,:on Linux/macOS,;on Windows). You can specify multiple directories to search in by separating them with the path list separator.Example:
export EXIFCOMMIT_PATH="$HOME/Pictures:$HOME/Documents/Images" # Linux/macOS set EXIFCOMMIT_PATH="$HOME/Pictures;$HOME/Documents\Images" # Windows -
EDITOR: This environment variable specifies the text editorexifcommitwill use to open the commit file. IfEDITORis not set,exifcommitwill default tovim. You can set it to your preferred editor (e.g.,nano,emacs,code,notepad++).Example:
export EDITOR="nano" # Use nano as the editor export EDITOR="code --wait" # Use VS Code (ensure `code` is in your PATH and `--wait` is used for proper workflow)
Example Scenario
Let's say you want to add the description "Photos from my vacation in Hawaii" to all .jpg files in your ~/Pictures/Hawaii directory.
-
Set
EXIFCOMMIT_PATH(optional but helpful for organized searches):export EXIFCOMMIT_PATH="$HOME/Pictures" -
Run
exifcommit:exifcommit HawaiiThis will:
-
Search for files with "Hawaii" in their name within
~/Picturesand the current directory. -
Create a temporary file and open it in your editor. The file might look something like this (contents are illustrative):
# First line of this file is used for the ImageDescription # An empty line aborts the change. # # Files to be modified, and their current value # (remove to exclude from editing): # file: /home/user/Pictures/Hawaii-beach1.jpg # current description of beach1.jpg # file: /home/user/Pictures/Hawaii-beach2.jpg # another description # file: /home/user/Pictures/Hawaii-sunset.jpg # not found
-
-
Edit the Commit File:
-
On the first line, type in the new description:
Photos from my vacation in Hawaii -
Review the file list. If you want to exclude
beach2.jpgfrom being modified, you can delete the line# file: /home/user/Pictures/Hawaii/beach2.jpg. -
The file should now look like this (if you kept all files and added the description):
Photos from my vacation in Hawaii # First line of this file is used for the ImageDescription # An empty line aborts the change. # # Files to be modified, and their current value # (remove to exclude from editing): # file: /home/user/Pictures/Hawaii-beach1.jpg # current description of beach1.jpg # file: /home/user/Pictures/Hawaii-beach2.jpg # another description # file: /home/user/Pictures/Hawaii-sunset.jpg # not found
-
-
Save and Close: Save the file and close your editor.
-
Verification:
exifcommitwill now apply the "Photos from my vacation in Hawaii" description toHawaii-beach1.jpgandHawaii-sunset.jpg(andHawaii-beach2.jpgif you didn't exclude it). You can verify the changes using an EXIF viewer or by runningexifcommitagain to check the current descriptions.
Important Notes:
- Backup Files:
exiftoolmight create backup files of your original images (typically with a.originalextension) in the same directory.exifcommitattempts to delete these backup files after successfully writing the EXIF tags using the-delete_original!flag ofexiftool. - Error Handling:
exifcommitprovides basic error handling and will print warnings or error messages to the console if issues occur. Check the output for any potential problems. exiftoolCompatibility: Ensure thatexiftoolis functioning correctly on your system independently before usingexifcommit.
Enjoy tagging your images!
Documentation
¶
There is no documentation for this package.