How to automate photoshop from the command line
I would recommend using imagemagick to do this. It is a suite of command line tools for image manipulation. mogrify is the one you want for this job.
mogrify -quality 100 *.jpg
There are several ways to set the quality, this just shows one.