Skip to content

Instantly share code, notes, and snippets.

@xorenio
Last active October 18, 2015 00:15
Show Gist options
  • Save xorenio/0f84443689a05eb09973 to your computer and use it in GitHub Desktop.
Save xorenio/0f84443689a05eb09973 to your computer and use it in GitHub Desktop.
BASH: Check for zips in directories
#!/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