I am looking to run a commend to find a .jpg or .gif in a directory or subdirectories and get the total count.
This what i have ""find . type f | grep -o ".[^.]+$" | sort | uniq -c"". What do i need to add to the script to have exclude directory folder00 when it dose the find?
WIth ExifTool you could do this:
exiftool -aaa -if '$filetype eq "JPEG"' DIR
It should list the files it finds, the print a summary like this:
1 directories scanned
82 files failed condition
21 image files read
The last line tells you how many JPEG files it found.
- Phil
To exclude folder00 from your find command and pick up jpg or gif files it would be something like this:
find . -path "./folder00" -prune -false -o \( -name "*.jpg" -or -name "*.gif" \) -print
I'm not sure exactly what you are trying to achieve
Im also not understanding the exact goal, so this some more examples to experiment with using the exiftool...
To list all jpegs and gifs (not caring about file-extensions), and being prejudice against 'folder00' as the parent-folder...
exiftool -r -if '$filetype =~ /(JPEG|GIF)/ and $directory !~ /\/folder00$$/' -p '$filepath' .
If only wanting the total-sentence from above, can pipe to sed like...
exiftool -v0 -r -if '$filetype =~ /(JPEG|GIF)/ and $directory !~ /\/folder00$$/' . |sed -n '$p'
If only wanting the total-number from above, can pipe to sed like...
exiftool -v0 -r -if '$filetype =~ /(JPEG|GIF)/ and $directory !~ /\/folder00$$/' . |sed -n '$s/ *\([0-9]*\).*/\1/p'
The commands are only being prejudice against parent-folder, so including images settled like... C:/path/folder00/AnotherFolder/image.ext
If to be prejudice against all folders named 'folder00' anywhere in the path, but also granting folders like 'aafolder00zz' ...
You can modify /\/folder00$$/ ===> /\/folder00($$|\/)/
The -i (-Ignore) option (https://exiftool.org/exiftool_pod.html#i-DIR--ignore) would be better than using an -if as long as you're not looking for a partial directory name.
But the original question really was more a linux/Mac command line question, so maybe this belongs in Other Discussions (https://exiftool.org/forum/index.php?board=1.0)?
Greetings StarGeek and welcome back! I was worried that maybe something bad happens to you?
Im never used this -i option before, but -i folder00 seems much better to exclude images anywhere below any folder named 'folder00'.
So the first -if would really only be better, if wanting to be prejudice against 'folder00' only when its a parent-folder, so being very unlikely.
Im really no idea what is the exact goal, but glad to know about the -i option, because Im always just conducting this with -if instead.
Now looking at his question, Im also thinking maybe he just wanted a shell script? Anyways, its good that you are back now!
Quote from: Luuk2005 on June 14, 2021, 06:54:35 PM
Greetings StarGeek and welcome back! I was worried that maybe something bad happens to you?
I have a failing HD the was intermittently corrupting files and was worried about losing thousands of pictures I've taken. See this post (https://exiftool.org/forum/index.php?topic=12579.0).