Skip to content

Instantly share code, notes, and snippets.

@japboy
Created April 18, 2011 02:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save japboy/924722 to your computer and use it in GitHub Desktop.
Save japboy/924722 to your computer and use it in GitHub Desktop.
Small scripts to do damn things automatically
#!/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
#!/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