I’ve run a batch process to resize and optimize all images within a directory and subdirectories. Unfortunately, Photoshop CC doesn’t have an option (that I’m aware of) to overwrite the existing images and instead creates a ‘JPEG’ directory anywhere it processes images and writes the processed images there. The number of images is relatively large (~2000 images) and they’re divided into hundreds of subdirectories, so manually moving the images to overwrites the existing ones is out of the question.
How can I move all of the processed images in the ‘JPEG’ directories up a level to overwrite the original images? The closes I think I’ve come is this:
find . -type d -name "JPEG" -exec cd {} ; && find . -type f -name "*.jpg" -exec mv -v {} .. ;
…but that drops all the images a level up from my current directory.
Can some one sort me out?
2
Answers
Your
cd
only affects a subprocess which changes to the directory and dies, while its parent process remains unaffected.Anyway, switching to a directory is rarely necessary or useful; just use the path directly in the
mv
command.(Not in a place where I can test right now, but I guess the wildcard needs a shell, too:
Untested, obviously.)
backup your image directory before using the following script.