Skip to content

Instantly share code, notes, and snippets.

@GeordieP
Created February 13, 2014 01:32
Show Gist options
  • Save GeordieP/8968092 to your computer and use it in GitHub Desktop.
Save GeordieP/8968092 to your computer and use it in GitHub Desktop.
#!/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