Created
February 6, 2010 18:07
-
-
Save davidreuss/296862 to your computer and use it in GitHub Desktop.
script for cleaning up files in download directory
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/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