Hello,
I need to find all image files from directory (gif, png, jpg, jpeg).
find /path/to/ -name "*.jpg" > log
How to modify this string to find not only .jpg files?
Thank you.
PS: Unix
Hello,
I need to find all image files from directory (gif, png, jpg, jpeg).
find /path/to/ -name "*.jpg" > log
How to modify this string to find not only .jpg files?
Thank you.
PS: Unix
find /path/to/ -name "*.gif" -o -name "*.jpg" -o -name "*.png" -o -name "*.jpeg"
will work. There might be a more elegant way.
dir /s *.jpg *.gif *.png *.jpeg > log
find searches the contents of files rather than the file system.
find /path -type f \( -iname "*.jpg" -o -name "*.jpeg" -o -iname "*gif" \)
find /path/to/ -type f -print0 | xargs -0 file | grep -i image
This uses the file
command to try to recognize the type of file, regardless of filename (or extension).
If /path/to
or a filename contains the string image
, then the above may return bogus hits. In that case, I'd suggest
cd /path/to
find . -type f -print0 | xargs -0 file --mime-type | grep -i image/
find /path/to -regex ".*\.\(jpg\|gif\|png\|jpeg\)" > log