Home All Groups Group Topic Archive Search About


Author
11 Aug 2005 4:26 AM
Mike
I have a group of folders that I would like to run the subinacl command on.
I think I need a script that read the folder name, passes this to the
command then repeats for the next name. Heres the set up:

D:\Data\user1
D:\Data\user2
D:\Data\user3    ..etc

The command I need to run is:
subinacl /subdirec "D:\Data\%username%\*.*" /setowner=Domain\%username%

so the commands would be:
subinacl /subdirec "D:\Data\user1\*.*" /setowner=Domain\user1
subinacl /subdirec "D:\Data\user2\*.*" /setowner=Domain\user2
subinacl /subdirec "D:\Data\user3\*.*" /setowner=Domain\user3

The folder names are the same as the domain username.

I'm a bit stumped as to where to start ...

Author
11 Aug 2005 5:00 AM
Marty List
Show quote
"Mike" <re***@togroup.com> wrote in message
news:%23NpNPzinFHA.3408@tk2msftngp13.phx.gbl...
>I have a group of folders that I would like to run the subinacl command on.
>I think I need a script that read the folder name, passes this to the
>command then repeats for the next name. Heres the set up:
>
> D:\Data\user1
> D:\Data\user2
> D:\Data\user3    ..etc
>
> The command I need to run is:
> subinacl /subdirec "D:\Data\%username%\*.*" /setowner=Domain\%username%
>
> so the commands would be:
> subinacl /subdirec "D:\Data\user1\*.*" /setowner=Domain\user1
> subinacl /subdirec "D:\Data\user2\*.*" /setowner=Domain\user2
> subinacl /subdirec "D:\Data\user3\*.*" /setowner=Domain\user3
>
> The folder names are the same as the domain username.
>
> I'm a bit stumped as to where to start ...


Check out the syntax of the FOR command:

C:\>for /?
<snip>
To use the FOR command in a batch program, specify %%variable instead
of %variable.  Variable names are case sensitive, so %i is different
from %I.
<snip>
FOR /D %variable IN (set) DO command [command-parameters]
    If set contains wildcards, then specifies to match against directory
    names instead of file names.
<snip>
    %~nxI       - expands %I to a file name and extension only
<snip>


The %variable would be any letter, like %I from the command line, or %%I
from a batch script.  So a batch script would look something like this:

@Echo Off
SetLocal ENABLEEXTENSIONS
Set SOURCE_FOLDER=D:\Data
For /D %%I In ("%SOURCE_FOLDER%\*") Do (
    Echo Processing "%%I" (DOMAIN\%%~nxI)
    Subinacl.exe /subdirec "%%I\*" /setowner="DOMAIN\%%~nxI"
)
Author
11 Aug 2005 6:08 AM
Mike
Perfect. Thank you Marty.

Show quote
"Marty List" <use***@optimumx.com> wrote in message
news:%23CiJVGjnFHA.3316@tk2msftngp13.phx.gbl...
>
> "Mike" <re***@togroup.com> wrote in message
> news:%23NpNPzinFHA.3408@tk2msftngp13.phx.gbl...
>>I have a group of folders that I would like to run the subinacl command
>>on. I think I need a script that read the folder name, passes this to the
>>command then repeats for the next name. Heres the set up:
>>
>> D:\Data\user1
>> D:\Data\user2
>> D:\Data\user3    ..etc
>>
>> The command I need to run is:
>> subinacl /subdirec "D:\Data\%username%\*.*" /setowner=Domain\%username%
>>
>> so the commands would be:
>> subinacl /subdirec "D:\Data\user1\*.*" /setowner=Domain\user1
>> subinacl /subdirec "D:\Data\user2\*.*" /setowner=Domain\user2
>> subinacl /subdirec "D:\Data\user3\*.*" /setowner=Domain\user3
>>
>> The folder names are the same as the domain username.
>>
>> I'm a bit stumped as to where to start ...
>
>
> Check out the syntax of the FOR command:
>
> C:\>for /?
> <snip>
> To use the FOR command in a batch program, specify %%variable instead
> of %variable.  Variable names are case sensitive, so %i is different
> from %I.
> <snip>
> FOR /D %variable IN (set) DO command [command-parameters]
>    If set contains wildcards, then specifies to match against directory
>    names instead of file names.
> <snip>
>    %~nxI       - expands %I to a file name and extension only
> <snip>
>
>
> The %variable would be any letter, like %I from the command line, or %%I
> from a batch script.  So a batch script would look something like this:
>
> @Echo Off
> SetLocal ENABLEEXTENSIONS
> Set SOURCE_FOLDER=D:\Data
> For /D %%I In ("%SOURCE_FOLDER%\*") Do (
>    Echo Processing "%%I" (DOMAIN\%%~nxI)
>    Subinacl.exe /subdirec "%%I\*" /setowner="DOMAIN\%%~nxI"
> )
>
>
>

AddThis Social Bookmark Button