Skip to content

Instantly share code, notes, and snippets.

@cpietsch
Created August 16, 2023 15:39
Show Gist options
  • Save cpietsch/7732afd0a638f29c9e4f3bbddf5efd90 to your computer and use it in GitHub Desktop.
Save cpietsch/7732afd0a638f29c9e4f3bbddf5efd90 to your computer and use it in GitHub Desktop.
bash script to extract automatic1111 output image metadata and generate a csv
#!/bin/bash
# Path to the directory containing folders with images
base_dir="/home/jovyan/stable-diffusion-webui/outputs/txt2img-images"
# Path to the ExifTool executable
exiftool_path="/home/jovyan/Image-ExifTool-12.65/exiftool"
# Loop through each folder in the base directory
for folder in "$base_dir"/*; do
if [ -d "$folder" ]; then
folder_name=$(basename "$folder")
csv_file="$folder_name.csv"
# Write CSV header
echo "ImageName,Parameters" > "$csv_file"
# Loop through PNG files in the folder
for image in "$folder"/*.png; do
if [ -f "$image" ]; then
parameters=$($exiftool_path -Parameters "$image" | awk -F ': ' '{print $2}')
echo "$(basename "$image"),$parameters" >> "$csv_file"
fi
done
echo "CSV file '$csv_file' created for folder '$folder_name'"
fi
done
@cpietsch
Copy link
Author

install Image-ExifTool or download it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment