I have files structure with subdirectories and image files inside. I want to use GraphicsMagick to convert image files to another format (and make them smaller). I can do it with simple command like this:
mogrify -path ../img-converted -format jpg ../content/*.jpg
But things get complicated, when I try to preserve subdirectory structure. Mogrify doesn't have this option, so I need to write shell script to check all directories (and maybe create new ones).
How this should be done?
Supposing Windows OS as question tagged
batch-file
.At first, using
robocopy
to copy all subfolder structure from source folder to the destination one. Then, looping through source folder and recurse it's subfolders, get full source and target (sub)paths and echo them. As not sure inmogrify
using therefore@echo mogrify ...
formulated in terms of my (mis)understanding it...That
nonexistingfilename
(could be replaced with^Nul
) inrobocopy %source% %target% nonexistingfilename /E
command assures copying folder structure only, no files. Using
*.jpg
instead will copy all*.jpg
as well:robocopy %source% %target% *.jpg /E