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 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 |
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 -print0
andxargs -0
rather thanls
, as if you have any filenames with spaces in, it will break thexargs mv
so like
find . -maxdepth 1 -print0 ! -name '_*' | xargs -0 -I '{}' mv {} ~/.Trash
...and maybe use
-type f
as a form of damage limitation?