Im sorting images in a kinda large image library, and thumbnails from old iPhoto-library is still in there. And I'm in need of removing them to improve speed of sorting the images.
I have found this answer here for linux, but how about macOS? Is there a way of searching a folder, recursively, and determine if the image *.jpg, *.png, *.bmp, *.jpeg
have the W360 and H270?
Running Sierra 10.12.4
Best Answer
Here is an example
bash
script that can achieve the goal natively, no need to install anything.All you need to do is set the
targetDir
variable to the starting point of where you want thefind
command to look. The default is the Pictures folder within your Home folder.Note: In the example script the
echo
command needs to be removed from in front ofrm "$filename"
in order for the files to actually be deleted and is there so you can first test the output of the script as to what files will be deleted. You can of course choose to remove it without testing and just go for it, if you're confident that you want to delete any .jpg, .png, .bmp or .jpeg file with dimensions of 270 pixel height by 360 pixel width within thetargetDir
.Also note that depending on the total file count of the target file extensions, the running of this script can take some amount of time to complete. On my system it found ~1000 files to delete out of 27500 files in my Pictures folder and took at least 5 to 10 minutes to complete.
That said, I ran this script, as it's written, and the only files other then the test file I created with the target dimensions, all other files found where in one specific location within my iPhoto Library bundle in the Thumbnails folder. So, wouldn't it just be easier to go into the bundle and delete the contents in Finder? That is, if it's really just those Thumbnails you want to get rid of!
If you don't know how to use the script, do the following in Terminal:
Copy and paste the script code from above into the opened
delete270x360images
document, modify as needed/wanted and then save and close.In Terminal, make it executable:
Now to use it in Terminal, type the following and then press enter.
Wait for it to complete.