Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Folder checking

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,59563
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Folder checking
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Folder checking - 4/28/2008 12:51:39 AM   
  chris_cs

 

Posts: 93
Score: 0
Joined: 10/9/2006
Status: offline
Guys,

I'm looking into writing a script that will help us keep track of all our folders on a network share. We are continually having issues where someone has moved a folder from one sub folder to another, and of course they deny all knowledge of this!

I'm thinking of using a script as a sheduled job to essentially check that all folders are in their correct location. I wondered how people would go about attacking this. I could obviously list all of the folders at the top of the tree and the browse downwards through their subfolders, but my problem is there are some fairly large subfolders containing up to 1000 subfolders.

Would my suggestion be the quickest way to do this? Once I get to the bottom of the tree I would just look at the folder names to make sure they are the correct type, as in start and end in the correct letters.

Any thoughts would be appreciated!
 
 
Post #: 1
 
 RE: Folder checking - 4/28/2008 1:04:17 AM   
  ebgreen


Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
Ok, so there are a couple of ways to do this. To be honest with you I would try both then see which is faster and easier to work with. Method one is to use the FileSystemObject to recurse through every folder building a data structure (I would use a dictionary) to hold all the data. The second method is to shell out to the Dir command and pipe the output of Dir to a text file. Then open the text file and build the same data structure from the contents of the file. Personally I think I would use Method 1, but both should get you to the same place.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to chris_cs)
 
 
Post #: 2
 
 RE: Folder checking - 4/28/2008 1:17:22 AM   
  dm_4ever


Posts: 2220
Score: 32
Joined: 6/29/2006
From: Orange County, California
Status: offline
If I remember correctly Dir.exe was several times faster than FileSystemObject when it came to large directories...so like ebgreen suggested...you might pipe it out to a text file.  Maybe keep a before and after text file and compare the data between the two using a dictionary, again like ebgreen suggested. 

You could also work on setting permissions to prevent certain things from happening, maybe some auditing, and if your company uses MS MOM (SCOM) then mayve write to the eventlog to generate alerts.

WMI can also be used for monitoring...maybe the Win32_Directory and the __InstanceModificationEvent class.

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to chris_cs)
 
 
Post #: 3
 
 RE: Folder checking - 4/28/2008 1:17:35 AM   
  chris_cs

 

Posts: 93
Score: 0
Joined: 10/9/2006
Status: offline
Thanks for the suggestions. So in terms of option 1, just so I have this right, I would basically add all of the paths to the dictionary object i.e

Folder\Subfolder1\AnotherFolder

Folder\Subfolder2\AnotherFolder

Folder\Subfolder2\AnotherFolder

Then I could navigate through my dictionary object and perform the folder name checks.

Is this what you mean?

(in reply to chris_cs)
 
 
Post #: 4
 
 RE: Folder checking - 4/28/2008 1:19:56 AM   
  ebgreen


Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
That wasn't what I meant, but it might work. What I meant was to go through the folders building a dictionary of "the way things are" then you would compare that to a seperate dictionary of "the way things should be". So I guess the first question would be how do you determine "the way things should be".

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to chris_cs)
 
 
Post #: 5
 
 RE: Folder checking - 4/28/2008 1:30:46 AM   
  chris_cs

 

Posts: 93
Score: 0
Joined: 10/9/2006
Status: offline
Ok well I think I have an idea of what you're getting at. I'll have a look into this and if I run into any problems I'll get back to you.

Thanks for the info 

(in reply to ebgreen)
 
 
Post #: 6
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Folder checking Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts