I require the script to cd to a directory, then delete all but a few files in sub-directories—but leave the folders alone. Would it help to use switch
How about this?
$ find /Users/YourName/Desktop/Test -type f -maxdepth 2 -not -name watch.log -delete
-type: look for files only-maxdepth: go down two levels at most-not -name (combo): exclude watch.log from the search-delete: deletes filesTry out the above command without the -delete flag first. That will print out a list of files that would have been deleted.
Once you’re happy with the list, add -delete back to the command.