If a folder contains sub-folders and files, is there a Terminal command to remove some sub-folders while not removing any files?
Rule-based deletions tend to be tricky and can easily go wrong. In your case the following might work
find &quot;parentFolder&quot; -depth 1 -type d ! -name subFolder1 -ok rm -r -- '{}' \;

This

only looks one level beneath parentFolder (-depth 1)
only looks at directories (-type d)
skips subFolder1 (! -name subFolder1)
prompts for the deletion of any non-skipped directories (-ok rm -r -- '{}' \;)

PS: To skip several directories use ! \( -name subFolder1 -o -name subFolder2 \), to delete without prompting use -exec rm -r -- '{}' +.