#119: Set execute permission for directories

I have a folder consisting of a mix of files and subdirectories, on OS X. I'm looking for a one-line script to set the execute permission bit only on all subfolders/subdirectories, without setting all the normal files to executable as well.

The usual chmod -R would set execute on everything.

Use the special permission X

So instead of using (for example) chmod -R g+rx ., use
chmod -R g+rX .

The capitalized X sets the executable bit only if the target is a directory. Per the man page:
The execute/search bits if the file is a directory or any of the execute/search bits are set in the original (unmodified) mode. Operations with the perm symbol ``X'' are only meaningful in conjunction with the op symbol ``+'', and are ignored in all other cases.

So you can't use it to remove executable bits on directories, but definitely can use it to set the executable permission bit.

Think you've got a better solution? Help 92049143cabb7ba896d7c06e19906303_small yliu out by posting your solution