Page 1 of 1 1
Topic Options
#45722 - 2003-09-20 07:49 PM Creating Folder Structures using an INI file
Grasshopper75 Offline
Getting the hang of it

Registered: 2002-01-15
Posts: 99
Loc: Melbourne, Australia
Hi All,

I'm attempting to create a new folder structure for my company using kix and an INI file. Basically what I am after is the following

code:
Group
|_ Department
|_Team
|_Folder A
|_Folder B

I am structuring my INI file as follows

code:
[Department]
Group=Groupname
Team=Teamname

Any ideas how I can use the ReadProfileString to create this folder structure ? I'm having troubles reading in all the sections as it appears to add a CRLF at the end which kills my script to create the folder structre.

code:
$inifile="T:\groups.ini"

$x=ReadProfileString($inifile,"","")
$y=ReadProfileString($inifile,$x,"Group")
$z=ReadProfileString($inifile,$x,"Team")

Use x: "\\datl003n\Corporate"

MD "x:\"+$y+"\"+$x
MD "x:\"+$y+"\"+$x+"\"+$z

Use x: /delete

Any help would be appreciated.

Cheers,
Grasshopper75

[ 20. September 2003, 20:03: Message edited by: Grasshopper75 ]

Top
#45723 - 2003-09-20 08:15 PM Re: Creating Folder Structures using an INI file
kholm Offline
Korg Regular
*****

Registered: 2000-06-19
Posts: 714
Loc: Randers, Denmark
ReadProfileString($inifile,"","")
Returnes a string with all sections in the inifile, separated by Chr(10), AND ending with Chr(10)

If only one section exist the returned value by:
ReadProfileString($inifile,"","")
is the sectionname + chr(10)

You could try using this:
code:
$inifile="T:\groups.ini"

$s=Split(ReadProfileString($inifile,"",""),Chr(10))
For Each $x In $s
If $x
$y=ReadProfileString($inifile,$x,"Group")
$z=ReadProfileString($inifile,$x,"Team")

Use x: "\\datl003n\Corporate"

MD "x:\"+$y+"\"+$z
MD "x:\"+$y+"\"+$x+"\"+$z

Use x: /delete
EndIf
Next

-Erik

Top
#45724 - 2003-09-20 08:45 PM Re: Creating Folder Structures using an INI file
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Grasshopper,
There is a fundamental flaw in your logic. There is no way to control with absolute certainty, the order of keys (values) in an INI file if it is written with the WriteProfileString() function or API. Since you are nesting folders, there is significance as to their order. You would be better off to have the whole folder structure as one key (value) data.

I.E.
[GroupName]
FolderA=department\team\folderA
FolderB=department\team\folderB

Then Split() out each folder level
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#45725 - 2003-09-20 08:55 PM Re: Creating Folder Structures using an INI file
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Another way would be to name them for their absolutew position in the folder heirarchy.

[GroupName]
level1=dept1|dept2|dept3
level2=team1|team2|team3
level3=foldera|folderb|folderc
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#45726 - 2003-09-20 11:08 PM Re: Creating Folder Structures using an INI file
Grasshopper75 Offline
Getting the hang of it

Registered: 2002-01-15
Posts: 99
Loc: Melbourne, Australia
I got it working thanks to kholm ! You saved me about 3 days work. Thanks.

code:
$inifile="c:\groups.ini"

$s=Split(ReadProfileString($inifile,"",""),Chr(10))
For Each $x In $s
$y=ReadProfileString($inifile,$x,"Group")
$z=ReadProfileString($inifile,$x,"Team")

MD "c:\"+$y+"\"+$x+"\"+$z
MD "c:\"+$y+"\"+$x+"\"+$z+"\A"
MD "c:\"+$y+"\"+$x+"\"+$z+"\B"
MD "c:\"+$y+"\"+$x+"\"+$z+"\C"
MD "c:\"+$y+"\"+$x+"\"+$z+"\A\CONTROLLED ACCESS"
MD "c:\"+$y+"\"+$x+"\"+$z+"\B\CONTROLLED ACCESS"
MD "c:\"+$y+"\"+$x+"\"+$z+"\C\CONTROLLED ACCESS"

Next

Cheers,
Grasshopper75

Top
#45727 - 2003-09-20 11:39 PM Re: Creating Folder Structures using an INI file
Grasshopper75 Offline
Getting the hang of it

Registered: 2002-01-15
Posts: 99
Loc: Melbourne, Australia
Now if anyone knows of a command line utility to set Advanced W2K permissions I'd be set. I need to do List permissions which neither CACLS or XCACLS seem to do.

Cheers,
Grasshopper75

Top
#45728 - 2003-09-20 11:40 PM Re: Creating Folder Structures using an INI file
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
SubInAcl
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#45729 - 2003-09-20 11:55 PM Re: Creating Folder Structures using an INI file
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Les, you seem to have fallen in love with SubInAcl [Big Grin]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#45730 - 2003-09-20 11:57 PM Re: Creating Folder Structures using an INI file
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
No, it won't make toast. [Frown]
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#45731 - 2003-09-21 06:50 PM Re: Creating Folder Structures using an INI file
Grasshopper75 Offline
Getting the hang of it

Registered: 2002-01-15
Posts: 99
Loc: Melbourne, Australia
I found a similar program and its free ! Does all permissions without the problems of SubinACL (Q296865) .

Its called SetACL and can be found here

Top
#45732 - 2003-09-21 06:55 PM Re: Creating Folder Structures using an INI file
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
now, subinacl and subinacl are totally different tools, as far as I know.
_________________________
!

download KiXnet

Top
#45733 - 2003-09-21 09:05 PM Re: Creating Folder Structures using an INI file
ChristopheM Offline
Hey THIS is FUN
*****

Registered: 2002-05-13
Posts: 311
Loc: STRASBOURG, France
you can use an other tool called FILEACL
look at http://membres.lycos.fr/jfb/gb/gbtools/fileacl.htm

with this tool, you can list permission and set them even for Win2K (inheritance, etc...)
_________________________
Christophe

Top
#45734 - 2003-09-21 11:03 PM Re: Creating Folder Structures using an INI file
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Q296865 only applies to certains versions of Subinacl.

Version 4.0.1.1613 does not have those problems.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#45735 - 2003-09-23 12:29 AM Re: Creating Folder Structures using an INI file
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
there was the answer I didn't deliver [Wink]
_________________________
!

download KiXnet

Top
#45736 - 2003-09-22 09:41 PM Re: Creating Folder Structures using an INI file
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
See also Tools for setting ACLs
_________________________
There are two types of vessels, submarines and targets.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 696 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.24 seconds in which 0.025 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org