Created
March 31, 2014 19:05
-
-
Save ed-george/9899756 to your computer and use it in GitHub Desktop.
Clean folder by moving all files not appended with underscore to Trash (Mac Only)
This file contains hidden or 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
| ls -1 | grep -v '^_' | xargs -I '{}' mv {} ~/.Trash |
Author
Seems to work fine with files that have a space.
But I must admit, I am not sure why.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You should probably use
find -print0andxargs -0rather thanls, as if you have any filenames with spaces in, it will break thexargs mvso like
find . -maxdepth 1 -print0 ! -name '_*' | xargs -0 -I '{}' mv {} ~/.Trash...and maybe use
-type fas a form of damage limitation?