Jump to content
Sign in to follow this  
kerlej

audit every subfolder in a given share

Recommended Posts

kerlej

Hi All

I need help with a project:

I need to audit every subfolder in a given share by:

1) Verifying XXXXX folder exists (I will provide a .txt file - folder per line)

2) If the folder exists check if 5 different text files exist. The filenames are varied (although follow a convention, ie but all contain the servername within it)

XXXXX_AB.txt,

AC_XXXXX.txt

XXXXXAB.txt

ABXXXXX.txt

AXXXXXB.txt

3) Write the result to a CSV file:

"FOLDER","FILE1","FILE2","FILE3","FI LE4","FILE5"

"TRUE","FALSE","TRUE","FALSE","TRUE& quot;,"FALSE"

4) Move on to the next folder

Any Ideas folks?

Cheers

Share this post


Link to post
Share on other sites
kerlej

*Anyone pretty please? (220 views!)

Hi All

I need help with a project:

I need to audit every subfolder in a given share by:

1) Verifying XXXXX folder exists (I will provide a .txt file - folder per line)

2) If the folder exists check if 5 different text files exist. The filenames are varied (although follow a convention, ie but all contain the servername within it)

XXXXX_AB.txt,

AC_XXXXX.txt

XXXXXAB.txt

ABXXXXX.txt

AXXXXXB.txt

3) Write the result to a CSV file:

"FOLDER","FILE1","FILE2","FILE3","FI LE4","FILE5"

"TRUE","FALSE","TRUE","FALSE","TRUE& quot;,"FALSE"

4) Move on to the next folder

Any Ideas folks?

Cheers

Share this post


Link to post
Share on other sites
omikron48

You can just use FileExists for testing whether a folder or file exists at a known location, if the path is expected and known beforehand. If the exact location isn't known, you can use FileFindFirstFile and FileFindNextFile to check the contents of a folder. (Don't forget to FileClose the seach handle afterwards.)

As for writing results into a file, you can use FileOpen (in write mode) for opening, FileWrite or FileWriteLine for writing, and FileClose afterwards to save the file.

Share this post


Link to post
Share on other sites
boogieoompa

Well thats quite a chore, typically you should post some code to show you have at least attempted this... fortunatly though I have beer and some time...

Your program will more or less look like this for the first 2 parts

Global $FileList=_FileListToArray("C:\Ben")
    Select
    Case @error = 1
        MsgBox (0,"","No Folder!")
        Exit    
    Case @error = 4 
        MsgBox (0,"","No Files Found.")
    Case Else
         ;add string filtering stuff, use stringsplit($filelist[$i],"_") if @error = 1 than it is the first 2, if not its the 2nd 2.
         ;once you divide it into those two groups you can use another stringlen to determine if it 1 or 2 
         ;and you can use stringsplit AND stringlen to determin if it 3,4,5 (with an "A" delimiator)
    EndSelect

Go to the help file and look up filewrite, its pretty straight foward. As far as moving to the next file you can just wrap the whole thing in a while statement (either by naming the folders methodically or by storing them in an array). Or of course you can just simply copy the function many times with a different explicit directory.

Good luck

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×