Cosmo is a command-line tool for managing and updating image metadata in bulk. It offers functionality to rename images sequentially and update metadata based on a CSV file input. This project leverages ExifTool to handle metadata extraction and updating.
- Bulk Metadata Update: Update image metadata (e.g., title, keywords, copyright status) based on a CSV file.
- Sequential Image Renaming: Rename images in a specified directory and export the results to a CSV file.
- Combined Processing: Run both renaming and metadata updates with a single command.
This project requires ExifTool to be installed on your system.
- On macOS: Use Homebrew
brew install exiftool- On Ubuntu/Debian: Use APT
sudo apt-get update
sudo apt-get install -y exiftool-
On Windows: Download and install ExifTool from the official website.
-
Chocolatey for windows:
choco install exiftoolgo version: 1.23
Install with go install (make sure you've installed go):
go isntall https://github.com/Roisfaozi/cosmo.git
cd cosmoOr use this soure code
-
Clone the repository:
git clone https://github.com/Roisfaozi/cosmo.git cd cosmo -
Install the required dependencies:
go get ./...
-
Build the project:
go build -o cosmo ./cmd/main.go
The rename command renames all images in a specified directory sequentially and exports the renaming information to a CSV file.
cosmo rename [directory] --ext=[file extension]cosmo rename ./testdata --ext=".jpg"This command renames all .jpg images in the ./testdata directory and saves the renaming details in renamed_files.csv within the same directory.
The update-metadata command updates the metadata of all images in a specified directory based on a CSV file.
cosmo update-metadata [csv-file]cosmo update-metadata ./testdata/metadata.csvThe CSV file should have the following columns:
SourceFile: Path to the image fileObjectName: Title or name of the object in the imageKeywords: Keywords associated with the imageCopyrightStatus: Copyright status of the imageMarked: Marked status (e.g., TRUE or FALSE)CopyrightNotice: Copyright notice information
The process command combines the functionality of both the rename and update-metadata commands.
cosmo process [directory] --ext=[file extension]cosmo process ./testdata --ext=".jpg"This command renames all .jpg images in the ./testdata directory and updates the metadata based on the metadata.csv file.
To run the tests, run the following command:
go test ./...For verbose output:
go test -v ./...To run specific tests, use the -run flag:
go test -v -run=TestUpdateMetadata ./...This project uses testify for assertions and exiftool for metadata handling.
If you would like to contribute to this project, please open an issue or submit a pull request. Thank you!
- Fork the repository.
- Create a new branch for your feature or bugfix.
- Commit your changes and push your branch.
- Open a pull request describing your changes.
This project is licensed under the MIT License.
Email: roisfaozi8@gmail.com
Website: roisfaozi.com
If you find this project useful, please consider supporting it by making a donation.
