Last active
October 18, 2015 00:15
-
-
Save xorenio/0f84443689a05eb09973 to your computer and use it in GitHub Desktop.
BASH: Check for zips in directories
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 | |
# This script makes zips of dirs in current dir if there is no zips in the dir | |
echo "" #Insert a break before any output | |
for D in *; do | |
if [ -d "${D}" ]; then # Check if dir | |
zip="$(echo $D | tr '[A-Z]' '[a-z]')" # Place letters with over cases | |
if [ -f "${D}/${zip}.zip" ]; then # Check to if there is a zip in the folder | |
# echo "found ${D}/${zip}.zip" # Tell users | |
else | |
echo "ERROR ${zip}.zip will be made" # Tell user | |
zip -r ${D}/${zip}.zip ${D} # Make zip | |
fi | |
fi | |
done | |
exit 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment