Created
February 12, 2017 00:51
-
-
Save orlovmax/9ef2c0ab17f72de898d9f6c62959c88f to your computer and use it in GitHub Desktop.
Bash gallery generator (slow)
This file contains hidden or 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 | |
# Options | |
title="Please specify type of gallery page" | |
prompt="Enter option number" | |
options=("Albums" "Images" "Quit") | |
# Show select menu | |
printf "$title \n" | |
PS3="$prompt: " | |
select opt in "${options[@]}" | |
do | |
case $opt in | |
"Albums") | |
printf "Albums gallery page succesfully generated! \nExiting..."; | |
break;; | |
"Images") | |
i=0 | |
echo "<html>" > index.html | |
echo "<head>" >> index.html | |
echo "<title>Gallery</title>" >> index.html | |
echo "<style>" >> index.html | |
echo "img {" >> index.html | |
echo "display: block;" >> index.html | |
echo "width: calc(100% - 100px);" >> index.html | |
echo "margin: 50px auto;" >> index.html | |
echo "}" >> index.html | |
echo "</style>" >> index.html | |
echo "</head>" >> index.html | |
echo "<body>" >> index.html | |
for i in `find ./*.jpg -maxdepth 1 -mindepth 0 -type f| sort`; do | |
file=`basename "$i"` | |
echo "<img src=\"$file\">" >> index.html | |
done | |
echo "</body>" >> index.html | |
echo "</html>" >> index.html | |
printf "Images gallery page succesfully generated! \nExiting..."; | |
break;; | |
"Quit") printf "Exiting... \n"; break;; | |
*) printf "Invalid option, try to enter the correct number from the list above \nExiting..."; break;; | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment