Mega Free Wallpapers Updates |
Bash script to sort wallpapers and pictures by their ratios and move them to subfolders Posted: 29 Oct 2013 04:06 AM PDT If you have a bunch of pictures which you want to sort and move into sub-folders according to their ratios (such as portrait, landscape, 16-10 wallpapers, 16-9 wallpapers etc), then this bash script I just wrote and successfully used to sort over a thousand pictures in just a couple of minutes may be the thing you need. It runs from the command line, and can be easily modified to suit other ratios. It creates the sub-folders first, and then reads the dimensions of each image and moves it to the appropriate sub-directory. It is written on a Linux PC and requires ImageMagick (installed by default on most distros). You can download the script via this link (make it executable before you run it) or you can copy & paste the code below. I was using a Python script called PyImgSort 0.1.6 : Python Package Index, however that one can be a bit complicated to edit if you want to change the ratios being sorted. The one I’ve written makes it nice and simple by keeping everything in the one file. The quotation marks around the $f variable mean that the script should work okay on file names with spaces in them. Hopefully you might find it helpful if you have a large number of pictures to sort. |
You are subscribed to email updates from Mega Free Wallpapers News To stop receiving these emails, you may unsubscribe now. | Email delivery powered by Google |
Google Inc., 20 West Kinzie, Chicago IL USA 60610 |