How to loop over a directory of files in Linux and perform a command on each file in turn. Examples below are using Ubuntu 12.04.
A quick one-liner for the impatient that will print out all .JPG files in the current directory
for f in *.jpg; do echo $f; done
It’s easier to read and understand when written out over multiple lines
for f in *.jpg do echo $f done
Inside the loop
$f is the name of the file, you could change your loop to use ImageMagick to convert the JPEG from using CMYK to RGB colorspace
for f in *.jpg do convert $f -colorspace RGB $f done