Skip to content

Instantly share code, notes, and snippets.

@davidreuss
Created February 6, 2010 18:07
Show Gist options
  • Save davidreuss/296862 to your computer and use it in GitHub Desktop.
Save davidreuss/296862 to your computer and use it in GitHub Desktop.
script for cleaning up files in download directory
#!/bin/zsh
[ -z "$1" ] && {
echo "What directory do you want me to look in?"
exit 1
}
[ -d "$1" ] || {
echo "'$1' doesn't look like a directory"
exit 1
}
cd "$1"
start=$(pwd)
#! \( -name "M*" \) ! \( -name ".*" \)
for dir in $(find "$1" -type d -depth 1 -prune); do
# echo "Entering directory: $dir"
cd "$start/$dir"
if [ $(ls -l | wc -l) -gt 1 ]; then
for file in $(ls *(oc[2,-1])); do
echo "Would delete file: $dir/$file"
done
else
echo "Skipping '$dir'.. no files for deletion."
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment