You might not need a batch file; you might be able to do it all with one command. Say you have a directory that contains mp3 files organized into subdirectories (artist, album, whatever), and the top directory is /usr/local/share/music. Now, let's say you wanted to make all of the mp3's readable by everyone. You could do this:
find /usr/local/share/music -type f -name "*.mp3" -exec chmod 644 {} \;
'-type f' => only select regular files
'-name "*.mp3"' => only select files with .mp3 extension
'-exec' => execute the following text as a command until you reach '\;'
'chmod 644 {}' => change the permission of the file found. {} is replaced with the matching file.
So now everybody can read those files, but you also need to make sure they can browse to the directories:
find /usr/local/share/music -type d -exec chmod 755 {} \;
'-type d' => only select directories
That will give everone read/execute permissions for the directories so they can list the contents and read files within, and give the owner read/write/execute.
Find is a great command, but if that isn't what you're looking for, I can help with creating a shell script. I'd need need more info on what exactly you're trying to accomplish (relationships between files/directories and things like that).
You can always use a brute force method by opening up a file, and typing all the commands one by one, and then telling bash to execute them (similar to a traditional windows batch file), but that's not saving you any effort as opposed to typing them all in at the command line.
Last edited by Dark_Helmet; 08-13-2004 at 03:02 PM.
|