2

I'm trying this piece of code to resize jpg files inside folder recursively larger than 1 MB.

find . -type f -size +1M -name "*.jpg" | xargs convert -resize 1000x1000\> -verbose 

Getting error message (which breaks batch after 15-20 iterations)

xargs: convert: terminated by signal 9 

How to solve this issue?

1
  • This is going to pass multiple filenames to convert which I don't think it handles correctly. Are you sure this is doing what you want and not stomping over a good chunk of your original files? Commented Mar 4, 2015 at 14:24

2 Answers 2

2

xargs from my experience aren't working good in all cases, just as a proposition, try to use -exec, if you need fast solution to the problem

find . -type f -size +1M -name "*.jpg" -exec convert {} -resize 1000x1000\> -verbose {} \; 

See if it will be helpful for you

Sign up to request clarification or add additional context in comments.

1 Comment

What if I need two {}'s?
0

xargs does not work properly if you have files with spaces in the name. In order for this to stand a chance of working, you should use the following syntax:

find . -type f -size +1M -name "*.jpg" -print0 | xargs -0 convert -resize 1000x1000\> -verbose 

This will insert null characters as separators instead of using spaces as separators.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.