On Sun, 15 Jun 2008 05:45:58 Rikard Johnels wrote:
Hello all!
I am (unsuccessfully) trying to arrange the usermod and permissions on some 5.000 folders and 20.000 files. (My music collection) I cant for my life compose a script that: a. Will set all directories to chmod 755 b, will set all regular files to perm 644
i tried a fairly simple script:
#!/bin/sh ls -R * | while read f do echo $f if [ -f $f ]; then chmod 644 $f fi done
the layout of the files is something like the following:
/1_sort/Bon Jovi/Crossroads (Best of 84-94)
Crossroad (best of 84-94) - 01 - Livin' On A Prayer.mp3 Crossroad (best of 84-94) - 02 - Keep The Faith.mp3 [...] Can anyone tell me what i do wrong, and how to write it properly?
Rikard, Your problem is most likely the spaces in the filenames; bash interprets each filename as a list of arguments rather than a file. You should be able to do it on the command line like this: To change all the subdirectories of the current working directory: find -type d -print0 | xargs -0 chmod 0755 This will find all directories under the current directory and set their perms to 0755. Similarly with the files: find -type f -print0 | xargs -0 chmod 0644. There was a whole thread on using xargs for this purpose a couple of months ago. See the man pages for xargs and find for more explanations. Hope this helps. -- =================================================== Rodney Baker VK5ZTV rodney.baker@iinet.net.au =================================================== George Orwell 1984. Northwestern 0. -- Chicago Reader 10/15/82