Hi.
I m working on linux, but i m not a command line guru so i need your help.
I have several images in several directory
directory\sub1
directory\sub2
directory\sub3
...
I succes to found a command to optimise them :
find directory -iname "*.jpg" | xargs mogrify *.jpg -sampling-factor 4:2:0 -strip -quality 85 -interlace JPEG -colorspace sRGB *.jpg
It's Working fine, it's replace orignal file my optimised file in correct subdir.
But my goal is to resize, optimise AND rename ..
So i tried
find directory -iname "*.jpg" | xargs mogrify -set filename:name %f -write 'suffix-%[filename:name]' -resize 177x -sampling-factor 4:2:0 -strip -quality 85 -interlace JPEG -colorspace sRGB *.jpg
And it's not workink as i want.
It's write new file in main directory, not in each sub.
How to solve my problem ?
Thanks
Convert or mogrify batch files in multiple directory
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Convert or mogrify batch files in multiple directory
Mogrify will not allow renaming. You will have to write a script loop over each image and write a specific name for each output. Or if you are on ImageMagick 7, you might be able to do the renaming for all files with your 'suffix-%[filename:name]' scheme in one command line, memory permitting.
Please, always provide your IM version and platform when asking questions, since syntax may differ. Also provide your exact command line and if possible your images.
See the top-most post in this forum "IMPORTANT: Please Read This FIRST Before Posting" at http://www.imagemagick.org/discourse-se ... f=1&t=9620
For novices, see
http://www.imagemagick.org/discourse-se ... f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
https://github.com/ImageMagick/usage-markdown
Please, always provide your IM version and platform when asking questions, since syntax may differ. Also provide your exact command line and if possible your images.
See the top-most post in this forum "IMPORTANT: Please Read This FIRST Before Posting" at http://www.imagemagick.org/discourse-se ... f=1&t=9620
For novices, see
http://www.imagemagick.org/discourse-se ... f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
https://github.com/ImageMagick/usage-markdown
Re: Convert or mogrify batch files in multiple directory
Hi.
I allready check lot of post here + other website.
and dont found the correct answer.
Platform : Ubuntu
Imagemagick : ImageMagick 7.0.7-31
i made a mistake in my first post .
I want to write a new file.
i have more than 1500 images in 300 directories.
my goal is to resize, optimise AND write the new image as a new file ..
I have
directory\sub1\image-01.jpg
directory\sub2\image-other-name-01.jpg
directory\sub3\image-different-name-01.jpg
i try to have
directory\sub1\image-01.jpg + directory\sub1\rz-image-01.jpg
directory\sub2\image-other-name-01.jpg + directory\sub2\rz-image-other-name-01.jpg
directory\sub3\image-different-name-01.jpg + directory\sub3\rz-image-different-name-01.jpg
The command line
find directory -iname "*.jpg" | xargs mogrify -set filename:name %f -write 'suffix-%[filename:name]' -resize 177x -sampling-factor 4:2:0 -strip -quality 85 -interlace JPEG -colorspace sRGB *.jpg
is not working as i want
I allready check lot of post here + other website.
and dont found the correct answer.
Platform : Ubuntu
Imagemagick : ImageMagick 7.0.7-31
i made a mistake in my first post .
I want to write a new file.
i have more than 1500 images in 300 directories.
my goal is to resize, optimise AND write the new image as a new file ..
I have
directory\sub1\image-01.jpg
directory\sub2\image-other-name-01.jpg
directory\sub3\image-different-name-01.jpg
i try to have
directory\sub1\image-01.jpg + directory\sub1\rz-image-01.jpg
directory\sub2\image-other-name-01.jpg + directory\sub2\rz-image-other-name-01.jpg
directory\sub3\image-different-name-01.jpg + directory\sub3\rz-image-different-name-01.jpg
The command line
find directory -iname "*.jpg" | xargs mogrify -set filename:name %f -write 'suffix-%[filename:name]' -resize 177x -sampling-factor 4:2:0 -strip -quality 85 -interlace JPEG -colorspace sRGB *.jpg
is not working as i want
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Convert or mogrify batch files in multiple directory
"find" makes a list of filenames. "xargs" calls "mogrify" which uses the input "*.jpg", to which xargs appends each of the filenames produced by "find".NoWayHome wrote:find ... xargs mogrify ... *.jpg
So, why do you have "*.jpg" as an argument to mogrify? What do you expect that to do?
I suggest you read documentation (eg man pages) for "find" and "xargs".
snibgo's IM pages: im.snibgo.com
Re: Convert or mogrify batch files in multiple directory
Thanks.snibgo wrote: ↑2018-05-09T06:23:50-07:00"find" makes a list of filenames. "xargs" calls "mogrify" which uses the input "*.jpg", to which xargs appends each of the filenames produced by "find".NoWayHome wrote:find ... xargs mogrify ... *.jpg
So, why do you have "*.jpg" as an argument to mogrify? What do you expect that to do?
I suggest you read documentation (eg man pages) for "find" and "xargs".
This arg was useless.
But it's not solving my main problem that is it's write file in main directory and not and each dir.
That's the problem i cant solve.
The first command ( replace ) was good
The second commande ( write new file ) dont works like i want.