Sips command shows 'not a valid file' warning

Extract dimensions from nested pictures


I used to be able to extract dimensions from nested pictures and to edit the resulting file with:

find . -name '*.jpg' -exec sips -g pixelHeight -g pixelWidth '\{\}' ';' | \

sed 's|.*/||' | \

sed 's|.*: ||' | \


line 1: The sips is recursive with the find on the files with .jpg to get the filename, height and width in pixel

line 2: remove the path

line 3: remove what precede ":" from the height line and from the width line


What I get is: Warning: \{\} not a valid file - skipping


What should I change ?

iMac (2017 – 2020)

Posted on Nov 15, 2025 2:03 PM

Reply
Question marked as Top-ranking reply

Posted on Nov 17, 2025 9:32 AM

Another approach using Awk for post processing:

find . -iname '*.jpg' -exec sips -g pixelHeight -g pixelWidth {} \; | awk -F "[:/]" '$0 ~ /\./ {print $NF}; $2 ~ /[0-9]/ {print $NF | "tr -d \" \""}'


That yields this output format:

IMG_9088.jpg
3024
4032
IMG_9062.JPG
800
600
IMG_9076.jpg
3024
4032


The key here is knowing tha that you can use multiple field separators "[:/]" to your advantage to get the last field (NF) for each find output line category.


Tested: macOS Tahoe 26.1 and BSD awk, not GNU awk.


4 replies
Question marked as Top-ranking reply

Nov 17, 2025 9:32 AM in response to Mike O'Mike

Another approach using Awk for post processing:

find . -iname '*.jpg' -exec sips -g pixelHeight -g pixelWidth {} \; | awk -F "[:/]" '$0 ~ /\./ {print $NF}; $2 ~ /[0-9]/ {print $NF | "tr -d \" \""}'


That yields this output format:

IMG_9088.jpg
3024
4032
IMG_9062.JPG
800
600
IMG_9076.jpg
3024
4032


The key here is knowing tha that you can use multiple field separators "[:/]" to your advantage to get the last field (NF) for each find output line category.


Tested: macOS Tahoe 26.1 and BSD awk, not GNU awk.


Nov 16, 2025 6:59 AM in response to Mike O'Mike

If you are seeking the folllowing output where the filename is contrived here for alignment purposes:


imagename1.jpg pixelHeight 3024 pixelWidth 4032
imagename2.jpg pixelHeight  800 pixelWidth  600


You could use this variation of the Find command:

find . -iname '*.jpg' -exec sips -g pixelHeight -g pixelWidth {} \; | egrep -o '([[:alnum:][:punct:]]+)' | sed 's|.*/||;s|:||' | xargs -n5 | sort -n


That will produce the following output format ascending by image name:



Nov 16, 2025 11:53 AM in response to VikingOSX

Thank you !


The output I was expecting in the past was with the 3 lines I showed was:


05P.jpg

594

403

04P.jpg

594

425

TP.jpg

818

818


And with :

find . -name '*.jpg' -exec sips -g pixelHeight -g pixelWidth {} ";" |

instead of my old :

find . -name '*.jpg' -exec sips -g pixelHeight -g pixelWidth '\{\}' ';' | \

followed by :

sed 's|.*/||' | \

sed 's|.*: ||' | \


I GET IT EXACTLY !!


What I used to do was to put filename & both dimensions on a same line and add the product (the number of pixel) at the end with the rather complex:


awk '\{printf "%s ",$0;h=w;w=$0\}!(NR%3)\{printf "%d\\n",h*w\}' | \


I then added "_" as a field separator:


awk '\{split($0,a,".jpg");gsub(/ /,"_",a[2]);print a[1]".jpg"a[2]\}' > final.txt\


I finally sorted by decreasing total number of pixel with:


sort -t"_" -rnk4 /Users/mike/Documents/\\ \\ Mike\\ multimedia/Art/final.txt > finalsorted.txt\


Could it be streamlined as well ?


Thank you !




Sips command shows 'not a valid file' warning

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.