Searching the system root and bellow for a file types matching

(imported topic written by SystemAdmin)

I have a need create an analysis to search the system root and all sub directories for type types matching “*.nsf” and report the directory, size and possibly when it was last accessed or modified.

Can anyone help?

(imported comment written by BenKus)

Hey Marcus,

When you say “system root” do you mean “C:” (or whichever drive the OS is installed on) or do you mean the system folder on Windows OSes?

Ben

(imported comment written by SystemAdmin)

“C:” or the drive the OS has been installed to.

(imported comment written by SystemAdmin)

Sorry, missed that this only relates to Windows systems

(imported comment written by brolly3391)

Hello Marcus,

Just for kicks, I ran this relevance on one of my test boxes:

q: names of descendants of folder “c:”

it took 60,000 microseconds (a full minute) of non-stop hard drive activity to complete and gave me a list of every file on my entire harddrive. This is on a test box with 4GB of files. I shudder to think of the time it would consume on a production box in the field.

I tell you this to encourage caution when you use the descendants operator. If you were to create a fixlet with relevance like that you could dramatically impact the speed of your BES Infrastructure.

With that said, you could use:

q: (name of it & “–” & size of it as string) of descendants whose (name of it ends with “.nsf”) of folder “c:”

A: a_brolly.nsf–62652416

A: l_brolly.nsf–720896

A: bookmark.nsf–10223616

A: headline.nsf–589824

A: decsdoc6.nsf–2078208

A: help65_client.nsf–10223616

A: lccon6.nsf–2883584

A: lsxlc6.nsf–1709568

A: readme.nsf–6291456

A: log.nsf–1050624

A: names.nsf–4456448

A: perweb.nsf–1350144

T: 8646.078 ms

I: plural string

That is down to 8 seconds but that speed improvement is at least partially due to Windows XP cacheing the DIR information from the first full scan I did. If you use it, put it in a retrieved property that evaluates daily to minimize the massive overhead that a full hard drive search brings. It would not be wise to use this in a task or fixlet.

A better implementation might be to limit the search to the installed Lotus Notes directory if it exists.

q: if exists key “HKEY_CURRENT_USER\Software\Lotus\Notes\Installer” whose (exists value “NOTESPATH” of it) of registry then ((name of it & “–” & size of it as string) of descendants whose (name of it ends with “.nsf”) of folder (value “NOTESPATH” of key “HKEY_CURRENT_USER\Software\Lotus\Notes\Installer” of registry as string)) else “Notes Not Installed”

A: a_Brolly.nsf–62652416

A: l_Brolly.nsf–720896

A: bookmark.nsf–10223616

A: headline.nsf–589824

A: decsdoc6.nsf–2078208

A: help65_client.nsf–10223616

A: lccon6.nsf–2883584

A: lsxlc6.nsf–1709568

A: readme.nsf–6291456

A: log.nsf–1050624

A: names.nsf–4456448

A: perweb.nsf–1350144

T: 128.728 ms

I: plural string

This worked for Notes 6, not sure if Notes 5 or before use that same registry key as a pointer to the installation. It’s a more narrow search but look at the difference in time. It’s 67x faster and much less of a resource hog. Do you really need to search the entire hard drive?

Oh, I did not see a file inspector for created or accessed or modified date of file. Maybe one of the experts has a good workaround for that.

Cheers,

Brolly

(imported comment written by jessewk)

brolly33

Oh, I did not see a file inspector for created or accessed or modified date of file. Maybe one of the experts has a good workaround for that.

See the section of your inspector guide. Lots of stuff there, including:

Q: modification times of files of folder “c:”

Q: creation times of files of folder “c:”

Q: accessed times of files of folder “c:”

There are many more properties, such as ‘hidden’, ‘normal’, ‘compressed’, ‘archive’, ‘readonly’, etc…

(imported comment written by brolly3391)

Jesse,

Reading up a bit, Filesystem Objects are files in the context of the file system that contains them with properties like Location, Parent and Compressed and File objects are files in the context of the file and it’s contents with properties like Content, Size, Section and Key.

Syntax for using both objects is the same so it did not occur to me that they were different objects with different properties. I was stuck in the File section.

Thanks for pointing that out for me.

Brolly

(imported comment written by BenKus)

Be careful with running the relevance above in a property. Please see: http://forum.bigfix.com/viewtopic.php?pid=1348#p1348

(imported comment written by amitspradhan)

My requirement is just a ste ahead of this. Over here, I am trying to search for all the MP3 files on the entire HDD (we have C and a D partition on every HDD), if any of the drives contain files wit a MP3 extension (irrestive of it being Hidden/Read Only…), then I need to create a action which will delete these files.

Now considering the fact, that the search will eat up the CPU, this action will be run at night.

I am still not able to crack the entire relevance and action…any ideas…?

(imported comment written by brolly3391)

Hello amitspradhan,

Check out the link that Ben provided above for a good overview. If you are still having problems with your relevance/action could you post what you have so far so we can try to troubleshoot?

Cheers,

Brolly

(imported comment written by JasonO91)

I’ve looked at a couple of ways to do this, and it seems like the fastest way to get the job done would be to use some unix utilities that were built for finding files. Then use a vbscript to actually delete the files.

Here’s how I was able to delete all mp3 files from the C:\ drive:

Download the unix utilities for Windows. They’re freely available from: http://unxutils.sourceforge.net/

Once you extract those files, you’ll want to upload the find.exe to the server so that you can download it with the client. (Standard software package deployment stuff)

Now that you have find.exe on the server, you’ll want a vbscript to run it. The task would look something like this:

continue if { (size of it =12345 and sha1 of it = “1234567890abcdefghijklmnop”) of file “big5D.tmp” of folder “__Download”}

extract big5D.tmp

wait __Download\find.exe

delete del_mp3.vbs

appendfile Set objShell = WScript.CreateObject(“WScript.Shell”)

appendfile Set objFSO = CreateObject(“Scripting.FileSystemObject”)

appendfile Set objExecObject = objShell.Exec("%comspec% /c find c:\ -name *.mp3")

appendfile Do While Not objExecObject.StdOut.AtEndOfStream

appendfile strText = objExecObject.StdOut.ReadLine()

appendfile If Instr(strText, “.mp3”) > 0 Then

appendfile objFSO.DeleteFile(strText)

appendfile End If

appendfile Loop

appendfile Wscript.Quit

move __appendfile del_mp3.vbs

wait “{pathname of client folder of site “BESSupport” & “\RunQuiet.exe”}” wscript.exe del_mp3.vbs

----->

This will download the find.exe, then create the vbs file to run and delete files as fast as possible.

If you want to test this script, change the “find c:” to “find c:\tmp” and put some files there.

Hope this helps.

Jason

(imported comment written by SystemAdmin)

That’s a good idea. It would be interesting to do the search using both the utility you mention and native relevance and compare the speeds.

Jim

(imported comment written by amitspradhan)

Hi Jason,

I tried the script, but it did not delete the mp3 files which I had placed in my C:\

Has any one else tried it?

(imported comment written by amitspradhan)

I have tried a simple batch file to delete all the audio files from a system. It works, but the only issue here is I am not able to delete any files which are hidden or renamed.

Can anyone suggest me a solution.

I am uploading the batch file which I used

(imported comment written by brolly3391)

Hello amitspradhan,

Your BAT file did not come through. You could paste its contents if you like.

Use might try the /a flag on your delete command in order to inclued non-visible files.

For example, if you wanted to delete all .XYZ files in all subdirectories on a windows machine using a BAT file you could do this:

c:

cd c:\

del *.xyz /s /a /q

It is simple, powerful, elegant and

extremely

dangerous. Use it at your own risk.

Cheers,

Brolly.

(imported comment written by amitspradhan)

It works…great…

I am pasting the contents of the batch file which I am using:

echo off

cls

A:

cd \

del *.mp3 /S /F /Q

del *.mp3 /S /F /Q /A:H

B:

cd \

del *.mp3 /S /F /Q

del *.mp3 /S /F /Q /A:H

C:

cd \

del *.mp3 /S /F /Q

del *.mp3 /S /F /Q /A:H

D:

cd \

del *.mp3 /S /F /Q

del *.mp3 /S /F /Q /A:H

E:

cd \

del *.mp3 /S /F /Q

del *.mp3 /S /F /Q /A:H

F:

cd \

del *.mp3 /S /F /Q

del *.mp3 /S /F /Q /A:H

G:

cd \

del *.mp3 /S /F /Q

del *.mp3 /S /F /Q /A:H

H:

cd \

del *.mp3 /S /F /Q

del *.mp3 /S /F /Q /A:H

I:

cd \

del *.mp3 /S /F /Q

del *.mp3 /S /F /Q /A:H

J:

cd \

del *.mp3 /S /F /Q

del *.mp3 /S /F /Q /A:H

K:

cd \

del *.mp3 /S /F /Q

del *.mp3 /S /F /Q /A:H

L:

cd \

del *.mp3 /S /F /Q

del *.mp3 /S /F /Q /A:H

M:

cd \

del *.mp3 /S /F /Q

del *.mp3 /S /F /Q /A:H

N:

cd \

del *.mp3 /S /F /Q

del *.mp3 /S /F /Q /A:H

O:

cd \

del *.mp3 /S /F /Q

del *.mp3 /S /F /Q /A:H

P:

cd \

del *.mp3 /S /F /Q

del *.mp3 /S /F /Q /A:H

Q:

cd \

del *.mp3 /S /F /Q

del *.mp3 /S /F /Q /A:H

R:

cd \

del *.mp3 /S /F /Q

del *.mp3 /S /F /Q /A:H

S:

cd \

del *.mp3 /S /F /Q

del *.mp3 /S /F /Q /A:H

T:

cd \

del *.mp3 /S /F /Q

del *.mp3 /S /F /Q /A:H

U:

cd \

del *.mp3 /S /F /Q

del *.mp3 /S /F /Q /A:H

V:

cd \

del *.mp3 /S /F /Q

del *.mp3 /S /F /Q /A:H

W:

cd \

del *.mp3 /S /F /Q

del *.mp3 /S /F /Q /A:H

X:

cd \

del *.mp3 /S /F /Q

del *.mp3 /S /F /Q /A:H

Y:

cd \

del *.mp3 /S /F /Q

del *.mp3 /S /F /Q /A:H

Z:

cd \

del *.mp3 /S /F /Q

del *.mp3 /S /F /Q /A:H

cls

:stop

exit

I used the software distribution wizard and the waithidden command to run this.

The only issue i now face is that it does not delete the mp3 files from a mapped network drive…which can overcome, since it anyways is going to even run on all Servers.