Model: claude-3-5-sonnet-latest
Write me a concise Bash script that loops through every .jpg or .jpeg in a directory and runs this against each one: llm -m gpt-4o-mini 'return just the alt text for this image' image1.jpg > image1.txt
Here's a concise Bash script that does what you've described:
#!/bin/bash
for img in *.{jpg,jpeg}; do
if [ -f "$img" ]; then
output="${img%.*}.txt"
llm -m gpt-4o-mini 'return just the alt text for this image' "$img" > "$output"
fi
doneThis script:
- Loops through all .jpg and .jpeg files in the current directory
- Creates an output filename by replacing the image extension with .txt
- Runs your llm command on each image and saves the output to the corresponding text file
- The
-fcheck ensures the file exists (prevents errors if no matches are found)
Save this as a .sh file, make it executable with chmod +x script.sh, and run it in the directory containing your images.