Can I change permissions on a directory?

Discussion in 'macOS' started by crotalus99, Jan 27, 2009.

  1. crotalus99 macrumors regular

    Joined:
    Dec 4, 2007
    #1
    Hi,

    I have a large music library that I have amassed over the years, but when I began ripping CDs there was no artwork on the iPod so it didn't matter, but now it would be nice to have it.
    I purchased a program called coverscout that finds artwork and automatically attaches it to the songs, but I have a problem.

    Somehow I have made every song read only. The program can't write the artwork to the tracks unless I change each one to rw. I tried to change just the directory, but that doesn't work.

    Is there a terminal command to change all files in a directory to read/write? Just for your information all the songs are organized in a folder called music then subfolder of the artist and then a subfolder to that of the albums. It would be great to just change it all and then when I'm done change it back to read only.

    Thanks for any help.


    Chris
     
  2. ffej2ffej macrumors newbie

    ffej2ffej

    Joined:
    Jan 27, 2009
    Location:
    Southern California
    #2
    changing attributes for all the files in a directory

    Have you tried sudo chmod +r+w *
    I think this should work but I'll admit I've never tried it. Good luck!
     
  3. sidewinder macrumors 68020

    sidewinder

    Joined:
    Dec 10, 2008
    Location:
    Northern California
    #3
    crotalus99,

    I would not use "sudo" here unless you have to.

    Once in the terminal program, use the "cd" command to get to the directory containing the music files. Your probably are the owner of the music files so you can type this command at the command prompt and hit return:

    chmod 755 *

    This command makes it possible for any program run as your user to modify the files. This is the same permission settings iTunes uses for music files it puts in the "iTunes Music" folder.

    You could use:

    chmod +w *

    This gives all users write permissions. But why not just set the permissions the way iTunes does and leave it at that. There is no need to make the files read only again.

    If the first command does not work, let us know what the errors are so we can help you solve the problem.


    S-
     
  4. macrem macrumors 65816

    macrem

    Joined:
    Mar 11, 2008
    #4
    Using chmod with numbers (e.g., "755") is good when working with all similar targets like all executables and folders or all non executable files. Working with an iTunes Library, for instance, there is a mixture of folders which should be executable to be accessible and music files which should be readable but not executable ("755" would make MP3's executable).

    The folders should already be executable and the music files should already be non executable. It appears to be a matter of making all files/folders in the library writable to the owner without granting other users write permissions, for ex.:

    chmod -R u+w ~/Music/iTunes/"iTunes Music"/*

    -R makes chmod dig into subfolders and u+w makes all files and folders within the hierarchy writable (+w) for the owner (u) only.

    Note: if you already ran some of the other chmod commands in this thread then you might want to reverse the executable files** and granting all users write permissions (-R go-w). With "ls -l", all folders should look like this: drwxr-xr-x & all files should look like this: -rw-r--r--

    Edit: **I never had a need to try this but will test later or maybe someone else can confirm that to change files only (not folders) back to being non-executable, use this command: chmod -R 0644 /path/to/top-level/music/folder

    As I understand, the first "0" will then cause the command to skip folders. "644" will make all files non executable, writeable by the owner, readable by the group and others.

    To do all of this with a nice graphical interface, some things can be done by highlighting the folder > command-i > go to "Sharing & Permissions"...

    or download a nice, free app called BatChmod
     
  5. sidewinder macrumors 68020

    sidewinder

    Joined:
    Dec 10, 2008
    Location:
    Northern California
    #5
    It was strange that my iTunes library had songs that were set to "755" permissions. I went and looked the rest of my library and only the album I chose to look at was "755". The rest are "644". I'll have to fix that.

    So I have to concur with macrem on this one and what I posted was wrong.

    This is indeed the command to use:

    chmod -R u+w ~/Music/iTunes/"iTunes Music"/*

    Assuming the music is in the path provided, that is.

    S-
     
  6. crotalus99 thread starter macrumors regular

    Joined:
    Dec 4, 2007
    #6
    Thanks so much guys.

    I did figure a way to do it last night, but now wonder if what I did was the same?

    I opened the info screen on the music directory, changed my permissions to read/write, then clicked the little gear which gave me the option to "apply to enclosed items"?

    Did this do the same thing? Sorry to be a noob at this. I really haven't worked a command line since DOS.

    Thanks

    Chris
     
  7. sidewinder macrumors 68020

    sidewinder

    Joined:
    Dec 10, 2008
    Location:
    Northern California
    #7
    Chris,

    No worries. What you did was perfect.

    S-
     
  8. macrem macrumors 65816

    macrem

    Joined:
    Mar 11, 2008
    #8
    Hey guys, btw I don't want to sound too serious about executable MP3s... Its a best practice (for security) to keep non-executable files non-executable. I don't know of any exploits for executable MP3's, but IMO it's easy to fix & better to not go there. But probably most would not notice a difference either way.
     
  9. macrem macrumors 65816

    macrem

    Joined:
    Mar 11, 2008
    #9
    You definitely never have to use the command line in OS X if you don't want to. I also listed two GUI solutions above and there are probably other GUI solutions too. Most users probably never mess around with their permissions in OS X.

    The UNIX command line is so versatile that many get sucked into its power and like to share tips about it, but we have to remember not everyone else is interested, which is fine.
     
  10. gnucom macrumors newbie

    Joined:
    Aug 25, 2009
    #10
    Modify permissions on just directories or files of a certain type.

    Hey all if you're intersted in changing the permissions on just directories or files, you should use this method:

    http://gnucom.cc/blog/?p=154

    Its much safer than simply chmod wildcards. This way, you only change what you want to change.
     
  11. belvdr macrumors 601

    Joined:
    Aug 15, 2005
    #11
    That leading zero will remove the SUID bit; it will still run on all files and folders it sees.

    Posted above as a link, except I wouldn't pipe it to xargs, are these commands. Piping to another command can lead to lengthy delays. I've run these commands for years on directories with hundreds of thousands of files and it is flawless.

    Change all directories under current directory to 755:

    Code:
    find . -type d -exec chmod 755 {} \;
    Change all files under current directory to 644:

    Code:
    find . -type f -exec chmod 644 {} \;
    You can substitute your directory in place of the dot in the above commands, i.e.:

    Code:
    find /Users/username/Music -type d -exec chmod 755 {} \;
    find /Users/username/Music -type f -exec chmod 644 {} \;
     

Share This Page