# chmod -R vs. spaces in filenames



## hazmat (Nov 7, 2002)

I am trying to do a recursive chmod, but it seems to choke on file with spaces in the names, as in all my MP3s.  Any suggestions on how to get around this?  What I want to do is essentially:

chmod 644 `ls -lR | grep .mp3`

The actual 'ls' command works fine, but chmod complains of the non-existing files because of spaces.

Thanks.


----------



## jwalk76 (Nov 7, 2002)

have you tried:

chmod -R 644 *.mp3


----------



## hazmat (Nov 7, 2002)

That doesn't work.  Only applies to the cwd.  This worked:

find . -name '*.mp3' -type f -print0 | xargs -0 chmod 644


----------



## kwalker (Nov 11, 2002)

>That doesn't work. Only applies to the cwd

This should work:

chmod 644 *.mp3 */*.mp3 */*/*.mp3


----------



## bwanabob (Nov 14, 2002)

> _Originally posted by hazmat _
> *That doesn't work.  Only applies to the cwd.  This worked:
> 
> find . -name '*.mp3' -type f -print0 | xargs -0 chmod 644 *



You know, about 4 years ago, we wouldn't be talking about chmod, find, xargs, grep, etc. on a Mac. I still shake my head in dis-belief. (In a good way!). 

Nice solution! I have taken this and added it as an alias in my .cshrc (it works on the SGI/Linux boxes too.)


bob..


----------

