How do I create a find and evict command which will remove specific filetypes from my Mac?

I'm in a bit of a rough spot. To sum things up, I'm trying to get more storage on my laptop and found out that my computer was making Archives. After checking off the "Optimize iCloud Storage" to stop this I moved one of the old archives, which was a colossal 13.76 gigabytes into the iCloud so that all of it could just be uploaded ands stay there... Except I have a whole new problem. Not only have most of them not been uploaded to the Cloud and thus been removed from my drive, but attempting to right click and remove download has done nothing.


Thankfully I found something of a solution in involving the "evict" command and some other trickery (quick tip by the way for anyone who ends up coming across this thread in the future, if moving, say, the iCloud folder to the Terminal window causes it to disappear from the Finder's sidebar, DO NOT PANIC, NOTHING HAS BEEN DELETED, and you can bring it back by using the "Add to Sidebar" menu under the File command on the upper left of the screen).


However, it seems almost as if the command has a "limit" to how many files it can try and remove at once; it keeps falling short of removing all the downloads. I've thought of a way to get around it and looking it up has yielded [something](https://apple.stackexchange.com/questions/350351/how-do-i-delete-a-group-of-files-ending-with-specific-characters) which looked like what I was looking for, but not exactly. What I want is a broad sweeping "evict" command, like this:


> find . -type f -exec brctl evict {} \;


directed at specific filetypes, not deletion. I've looked up and down and I've found nothing, so I've come here for help.


The types of filetypes I am specifically looking to remove with this command are images (.jpg, .png, .jpeg, .gif, etc.) and videos (.mp4, .mov.)


If you want to mimic the overall evict process yourself, here are some instructions: Open terminal, type


> CD


in all caps and with a space in front of it, click and drag (as an example) the iCloud Documents folder to the Terminal Window - this should generate the path to the folder - and then put in this command:


> find . -type f -exec brctl evict {} \;


DO NOT ADD ANY SPACES OR ANYTHING TO THE COMMAND. Hit return and the process should start. From there you just wait, check on the storage space of your computer and see that some things don't get chosen for eviction. You can try this on any folder I guess but I don't know what happens to files if you smack it onto a non-iCloud folder and I'm not willing to test it out.


I've burned my entire afternoon on this and I'm frankly aggravated as ****. I wanted to have a fun relaxing time and instead I've practically been dueling my computer.


Lastly, apologies if anything isn't clear or seems off. This is my first time posting on this site and I'm not very attuned to this kind of thing.


[Edited by Moderator]

Posted on Sep 10, 2023 2:10 PM

Reply
1 reply

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How do I create a find and evict command which will remove specific filetypes from my Mac?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.