Created
April 18, 2011 02:40
-
-
Save japboy/924722 to your computer and use it in GitHub Desktop.
Small scripts to do damn things automatically
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 | |
SHA1SUMS='SHA1SUMS' | |
if [ ${#} -ne 1 ] | |
then | |
echo "Usage: bash $0 /path" | |
exit 1 | |
fi | |
if ! test -d ${1} | |
then | |
echo 'Invalid argument. Argument must be a correct path.' | |
exit 1 | |
fi | |
WORK_PATH=${1} | |
find ${WORK_PATH} -depth 1 -type f -name "${SHA1SUMS}" -exec rm -f {} \; | |
for FILE_PATH in `find ${WORK_PATH} -depth 1 -type f` | |
do | |
if [ ${FILE_PATH##*/} != ${SHA1SUMS} ] | |
then | |
echo `openssl sha1 ${FILE_PATH} | sed 's/SHA1(.*)= //'` \ | |
"*${FILE_PATH##*/}" \ | |
>> ${FILE_PATH%/*}/${SHA1SUMS} | |
fi | |
done |
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 | |
BLACKLIST=('._*' | |
'.AppleDB' | |
'.AppleDesktop' | |
'.AppleDouble' | |
'.DS_Store' | |
'.localized' | |
':2e*' | |
'desktop.ini' | |
'Network Trash Folder' | |
'Temporary Items' | |
'Thumbs.db') | |
if [ ${#} -ne 1 ] | |
then | |
echo "Usage: bash $0 /path" | |
exit | |
fi | |
if ! test -d ${1} | |
then | |
echo 'Invalid argument. Argument must be a correct path.' 1>&2 | |
exit 1 | |
fi | |
WORK_PATH=${1} | |
for (( I = 0; I < ${#BLACKLIST[@]}; ++I )) | |
do | |
find ${WORK_PATH} -name "${BLACKLIST[${I}]}" -exec rm -fir {} \; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment