• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 255
  • Last Modified:

Walking a directory to change rights


I have a folder that contains several hundred level 1 folders.  Each folder has 5 subfolders.  I need to change the access rights on two of the subfolders in each level 1 folder ... I can use an CACLS cmd to make the changes I need but would like to do this in a script or .bat file ..
0
kwandtke
Asked:
kwandtke
  • 2
  • 2
1 Solution
 
Bill PrewCommented:
This should be pretty easy to do, what are the names of the folders you need to change?  And are they different than any of the level1 folders?  We can build off the DIR command in a BAT file to get the job done if so.  Or we can do a little more work in the BAT if needed.  To give you an idea try the following command:

dir c:\base\changeme /ad /s /b

Where c:\base is the folder at "level 0" in your example, and "changeme" is one of the level 2 folders you will need to change.

If this shows just the folders you want to change let me know and I'll build from there.

~bp
0
 
t0t0Commented:
There are two principle approaches to this.

Are the names of the sub-folders to be changed, the same names in all the level 1 folders?
0
 
kwandtkeAuthor Commented:
The level1 folders are all different names .. the level2 folders are the same from one set to the next .. so it would be:

  folder A
        Costing
        Estimates
        Sched
        Proposal
 folder B
        Costing
        Estimates
        Sched
        Proposal

I need to remove a groups access from Estimates and Proposal
0
 
Bill PrewCommented:
Try this.  right now it is just doing an ECHO with the dirs to process, you can add the command that you need for each dir.  Set BaseDir to the directory that contains your level 1 folders, notice no trailing backslash on that.

~bp
@echo off
set BaseDir=c:
for /d %%A in ("%BaseDir%\*") do (
  echo CACLS "%%A\Estimates"
  echo CACLS "%%A\Proposal"
)

Open in new window

0
 
t0t0Commented:
something similar to billprew's code (although, I'm surprised he never asked the same question earlier)...

Drop the following batch file into the folder where all your 'level 1' folders are and run it from there...


@echo off
for /d %a in (*) do (
   cacls "%%a\Estimates\"
   cacls "%%a\Proposal\"
)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now