LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Desktop (http://www.linuxquestions.org/questions/linux-desktop-74/)
-   -   Script to find wallpaper images (http://www.linuxquestions.org/questions/linux-desktop-74/script-to-find-wallpaper-images-815326/)

1veedo 06-20-2010 08:12 PM

Script to find wallpaper images
 
So I have thousands of wallpapers scattered around my harddrive. Is there any way to scan for images with certain dimensions, ie your screen resolution?

frandalla 06-21-2010 01:31 AM

try the script below.
See the comments in the script for usage and dependencies.
tested on slackware 13.1

#!/bin/bash
#Script By Francisco Dalla Rosa Soares - 2010/06/21
#
#USAGE: teste.sh <directory to search> <what to search>
#
#EXAMPLE: teste.sh /home/myuser *.jpg
#
#The script will return the path to the files that meet the image dimensions specified.
#
#Image dimensions are in the array WALLPAPERSIZE.
#You can add or remove sizes as you want.
#This script DEPENDS on exiv2 for checking image dimensions

WALLPAPERSIZE=( 800x600 1024x768 1200x600 1680x1050 1920x1200 1280x800 1600x1200 1280x1024 )
for i in $(find $1 -iname $2); do
FILENAME=`exiv2 $i 2>/dev/null | grep "name" | awk -F: '{print $2}'`;
IMAGESIZE=`exiv2 $i 2>/dev/null | grep "Image size" | awk -F: '{print $2}'| sed 's/ //g'`;
for j in ${WALLPAPERSIZE[@]}; do
if [ $j == $IMAGESIZE ]
then
echo $FILENAME;
fi
done
done

1veedo 06-21-2010 11:10 AM

Awesome, that's exactly what I was looking for!


All times are GMT -5. The time now is 03:00 PM.