The trick here is that the 4th level needs to have all files and
subfolders to have everyone set as full access.
How do I create a routine that will set my two different levels of
permissions on directories in such a structure?
Thank you for the help!
Count the backslashes and use the count variable to identify which set of
permissions should be applied.
Some example folder structures would be useful for a solution (need to know
if the 4 levels are 2 to 6 levels deep from the root for example).
Would be an example of a full address to Email1.eml
I would guess that I would be using a dir /b /s > directory.txt to get
the directory structure in a file
Then I would be using a for %%z in (directory.txt) do cacls /g
everyone:f %1
not sure though on how to count the backslashes, or if my commands are
the correct ones.
Thank you for the replies.
On Jul 2, 7:51 pm, foxidrive <got...@woohoo.invalid> wrote:
>
> On Jul 2, 7:51 pm, foxidrive <got...@woohoo.invalid> wrote:
>> On Wed, 2 Jul 2008 15:42:55 -0700 (PDT), j...@aoitconsulting.com wrote:
>> >I am trying to set permissions on 4 levels of directories. The first
>> >three levels should all be set to WFAdmins to have full rights, domain
>> >admins to have full rights, and everyone else to have read and list
>> >rights.
>>
>> >The trick here is that the 4th level needs to have all files and
>> >subfolders to have everyone set as full access.
>>
>> >How do I create a routine that will set my two different levels of
>> >permissions on directories in such a structure?
>>
>> Count the backslashes and use the count variable to identify which set of
>> permissions should be applied.
>>
>> Some example folder structures would be useful for a solution (need to
>> know
>> if the 4 levels are 2 to 6 levels deep from the root for example).
>
> W:\001\090\023\Emails\Email1.Eml
>
> Would be an example of a full address to Email1.eml
>
> I would guess that I would be using a dir /b /s > directory.txt to get
> the directory structure in a file
> Then I would be using a for %%z in (directory.txt) do cacls /g
> everyone:f %1
>
> not sure though on how to count the backslashes, or if my commands are
> the correct ones.
>
> Thank you for the replies.
>
This solution developed using XP
It may work for NT4/2K
----- batch begins -------
[1]@echo off
[2]del result1.txt 2>nul
[3]del result2.txt 2>nul
[4]del result3.txt 2>nul
[5]del result4.txt 2>nul
[6]for /f "tokens=*" %%i in ( ' dir /s/b/a:d \106x ' ) do for /f
"tokens=3*delims=\" %%a in ("%%i") do set ysl=%%b&if defined ysl
(>>result1.txt echo\%%i) else (>>result2.txt echo\%%i)
[7]for /f "tokens=*" %%i in ( ' dir /s/b/a:-d \106x ' ) do for /f
"tokens=3*delims=\" %%a in ("%%i") do set ysl=%%b&if defined ysl
(>>result3.txt echo\%%i) else (>>result4.txt echo\%%i)
------ batch ends --------
Lines start [number] - any lines not starting [number] have been wrapped and
should be rejoined. The [number] that starts the line should be removed
The spaces surrounding the single-quotes are for emphasis only. The SPACES
are not required but the single-quotes ARE required.
C:\106x... is my test directory.
result 1 and result2 contain the list of directories which have 3 or more
levels/fewer than 3 levels
result 3 and result4 contain the list of files which have 3 or more
levels/fewer than 3 levels of directory.
...that should get you started.
>W:\001\090\023\Emails\Email1.Eml
>
>Would be an example of a full address to Email1.eml
>
>I would guess that I would be using a dir /b /s > directory.txt to get
>the directory structure in a file
>Then I would be using a for %%z in (directory.txt) do cacls /g
>everyone:f %1
>
>not sure though on how to count the backslashes, or if my commands are
>the correct ones.
This code will allow you to set the permissions for the files in the folder
at each level from the root folder. The cd by itself just reports the
folder it is in - so run it and see what is echoed.
@echo off
setlocal
for /f "tokens=1-6 delims=\" %%a in ('dir /a:d /o:n /b /s') do (
if "%%f"=="" if not "%%e"=="" (
cd "%%a\%%b\%%c\%%d\%%e"
cd
echo cacls level 4
cd..
cd
echo cacls level 3
cd..
cd
echo cacls level 2
cd..
cd
echo cacls level 1
pause
)
)
Thank you so much.
Also thank you billious for the response, but I couldn't understand
the scripting, and was afraid that I would kill it when I edited it.
On Jul 3, 1:57 am, foxidrive <got...@woohoo.invalid> wrote: