linux - How can I run a command on all files in a directory and mv to a different the ones that get an output that contains 'Cannot read TIFF header'? -
i'd remove bad tiffs out of large directory. commandline tool "tiffinfo" makes easy identify them:
tiffinfo -d *
this have ouput this:
00074000/74986.tif: cannot read tiff header.
if tiff file corrupt. if happens i'd take file , move different dirrectory: bad_images. tried using awk on this, hasn't worked far... thanks!
assuming "cannot read tiff header" error comes on standard error, , assuming tiffinfo
outputs other data on standard out don't want, then:
cd /path/to/tiffs file in `tiffinfo -d * 2>&1 >/dev/null | cut -f1 -d:` echo mv $file /path/to/bad_images done
remove echo
move files, once satisfied script work expected.
Comments
Post a Comment