LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-07-2005, 12:20 PM   #1
waitingforOES
LQ Newbie
 
Registered: Mar 2005
Posts: 1

Rep: Reputation: 0
Script to change folder permissions


I'm using Suse linux. I have 40 folders that have the same stucture of subfolders.

I need to run a script that will go through the 40 folders, find a specific subfolder in each one, and change permissions to that subfolder in each one of the 40 different folders.

for example:

video--->simpsons--->Divx
video--->sopranos--->Divx
video--->NYPDblue--->Divx

I need the script to search "simpsons", "sopranos", "NYPDblue", find subfolder "Divx" and change the permissions to rwx for everyone.

P.S: I have never written a script for linux, and don't know if there is a seperate program I have to install to enable scripts.

Thanks
 
Old 03-07-2005, 01:34 PM   #2
mjrich
Senior Member
 
Registered: Dec 2001
Location: New Zealand
Distribution: Debian
Posts: 1,046

Rep: Reputation: 45
Well, there are many ways to do this, from simply using the KFind gui and something like Konquoror, to writing a short script in Python, Perl, C, C++, or any other language that springs to mind. The simplest way, IMHO, is simply to use the "find" command that should be available on every system. Type man find into a shell to see what is possible (nearly everything is - it's a powerful command... beware ). But essentially what you want is something like the following:
Code:
find / -name 'Divx' -exec chmod -Rv a+rwx \{\} \;
In other words - ' find all files/directories starting from / named Divx, change the attributes recursively to rwx, and do it verbosely'. If you're likely to be doing this often, then you could paste the above into a file, change the file mode to executable (chmod u+x <filename>), and then all that would be left is to type ./ <filename> into a shell (in the same directory) to run it all over again.

From memory, SuSE doesn't include either Python nor the Gcc compiler by default (just install using Yast if wanted) but Bourne Shell scripts will be fine. For more info on shell scripts, have a read of Bash Guide for Beginners and later, Advanced Bash Scripting.

Cheers,

mj
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
FOLDER permissions change automatically Echo Kilo Linux - Newbie 5 08-21-2005 03:09 AM
permissions difference between /home/..../folder and /root/folder darkleaf Linux - General 3 07-21-2005 05:23 PM
Absolutely CANNOT change folder permissions help! leemoreau Ubuntu 4 04-26-2005 10:30 PM
Folder permissions help Seventh Linux - Newbie 2 04-22-2004 05:56 PM
Change folder permissions eggoz Linux - Newbie 2 03-17-2003 01:35 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:41 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration