8

The Background: I have a python script that generates a bunch of images (png format, minimum of several hundred), runs ffmpeg to turn them into a short video, and then puts all of the images into a zip archive so I can go back if I find any strange or interesting things where I want the individual frame.

The Issue: Originally the zip portion read as zip -q -T -m output *.png but that suppressed all the output, including the statement as to whether the file is ok. Is there a way to suppress the large number of updating: Stars0053.png (deflated 5%) without suppressing the output of the -T switch?

3
  • does adding this behind it work: |grep updating >/dev/null ?
    – Rinzwind
    Jun 17, 2011 at 14:08
  • For some reason that's suppressing the -T output line as well. Is the >/dev/null maybe applying to the output of both zip and grep?
    – thegrinner
    Jun 17, 2011 at 14:18
  • Maybe the zipfile module from Python's standard lib can do what you want (it has a testzip() method). Jun 17, 2011 at 15:11

2 Answers 2

12
zip -q -T -m output *.png  && echo "success" || echo "failure"

should work too, alternative to the solution, given in the comments.

It works like this: If the first commmand (zip ...) succeeds, the following combination with && can succeed too and is performed. But if the first part fails, then the whole combination will fail, and the &&-part is skipped, but an or-combination is successfull if one of both is successful, so the ||-part is performed.

You aren't interested in the combined result (true/false), but in the side-effect: a status feedback.

2
  • Wow, that's pretty much exactly what I was looking for. Thanks!
    – thegrinner
    Jun 17, 2011 at 17:00
  • -q --quiet Quiet mode; eliminate informational messages and comment prompts. (Use‐ ful, for example, in shell scripts and background tasks).
    – Íhor Mé
    Feb 22, 2020 at 14:17
1

Alternatively you can use pythons own zip library:

http://docs.python.org/library/zipfile.html

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .