Created
February 13, 2014 01:32
-
-
Save GeordieP/8968092 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# A script to extract the wallpapers from the Caledonia wallpaper collection | |
for directory in *; do | |
cd "$directory" | |
if [ -d 'content' ]; then | |
cd 'content' | |
elif [ -d 'contents' ]; then | |
cd 'contents' | |
fi | |
cd 'images' | |
NUM_IMGS=$(ls | wc -l) | |
if [ $NUM_IMGS == '1' ]; then | |
file_ext=$(ls | cut -d \. -f2) | |
cp * "/home/gp/Pictures/Caledonia/$directory.$file_ext" | |
else | |
highestRes=0 | |
for image in *; do | |
imgRes=$(echo $image | cut -d x -f1) | |
if [ $imgRes -ge $highestRes ]; then | |
highestRes=$imgRes | |
fi | |
done | |
file_ext=$(ls | grep -m 1 $highestRes | cut -d \. -f2) | |
cp $(ls | grep -m 1 $highestRes) "/home/gp/Pictures/Caledonia/$directory.$file_ext" | |
fi | |
cd ../../.. | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment