Created
January 25, 2024 09:48
-
-
Save sarkrui/7280f0dcf78671990358a9ae8559f035 to your computer and use it in GitHub Desktop.
Shutcount script for Fuji cameras
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
process_file() { | |
photo_path=$1 | |
if ! command -v exiftool &> /dev/null; then | |
echo "exiftool could not be found. Attempting to download and install it." | |
# Creating the Downloads directory if it doesn't exist | |
mkdir -p ~/Downloads | |
# Downloading the exiftool package | |
curl -L https://cachefly.aooo.nl/exiftoo.zip -o ~/Downloads/exiftool.zip | |
# Unzipping the downloaded file | |
unzip -o ~/Downloads/exiftool.zip -d ~/Downloads/ | |
# Installing exiftool using the installer command | |
sudo installer -pkg ~/Downloads/exiftool.pkg -target / | |
# Check again if exiftool was successfully installed | |
if ! command -v exiftool &> /dev/null; then | |
echo "Failed to install exiftool. Please install it manually." | |
return 1 | |
fi | |
fi | |
SerialNumber=$(exiftool -SerialNumber "$photo_path" | awk -F': ' '{print $2}') | |
ImageCount=$(exiftool -ImageCount "$photo_path" | awk -F': ' '{print $2}') | |
LensInfo=$(exiftool -LensInfo "$photo_path" | awk -F': ' '{print $2}') | |
Model=$(exiftool -'Model' "$photo_path" | awk -F': ' '{print $2}') | |
file_name="${Model// /}_${SerialNumber}_${ImageCount}.txt" | |
echo "Serial Number: $SerialNumber" > "$file_name" | |
echo "Image Count: $ImageCount" >> "$file_name" | |
echo "Lens Info: $LensInfo" >> "$file_name" | |
echo "Fuji Model: $Model" >> "$file_name" | |
echo "Information saved to $file_name" | |
} | |
shutcount() { | |
if [ $# -eq 0 ]; then | |
for photo_path in *.JPG; do | |
if [ -f "$photo_path" ]; then | |
process_file "$photo_path" | |
fi | |
done | |
else | |
process_file "$1" | |
fi | |
return 0 | |
} | |
# Main Execution | |
shutcount "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment