Hello,
I’d like to create a macro that will delete all files in a given folder which don’t contain the word “Episode”. Is there a relatively simple way to accomplish this?
Hello,
I’d like to create a macro that will delete all files in a given folder which don’t contain the word “Episode”. Is there a relatively simple way to accomplish this?
First off, don't even start to think about this macro until you've verified that your Mac is fully and completely backed up. Any small error in this macro could delete most of your harddisk!
When you have backed up your Mac completely, and then made a clone of your harddisk, you can create a macro something like this:
Path
in Folder Contents collection.
Path
does not contain “Episode”
But again, note that if you make any errors in creating a macro based on that, you could trash your entire contents of your Mac rendering it unbootable.
@peternlewis has provided the solution.
I am always very careful about allowing files to be deleted automatically since, as already said, a mistake can lead to an unusable Mac.
What I do, therefore, is temporarily replace the Trash
action with an Append to Variable
action and then at the end of the macro (outside the For Each
action) display the contents of the variable so I can see the path names of all the files that the macro will delete. That way I can immediately see whether the macro is safe to run.
Just a tip to help keep you safe - hope that helps
Silly question, perhaps -- but do you mean "files whose name doesn't contain the word Episode
" or "files whose contents..."?
First thought about using any kind of scripting system to perform deletions:
Don't do it.
( like taking a buzz-saw to a boiled egg – nothing good will come of it )
Thanks for everyone’s help as I was able to edit an existing macro posted by someone trying to accomplish a similar task and it works great. I was very careful to test it and I feel confident that it’s safe. I’m also extremely diligent about multiple backups. Thanks again everyone…