I’m developing a relevance analysis that will report the content of D:\ Drive.
I’ve the following code at the moment:
((pathnames whose ( it does not contain "Recycle.Bin" ) of it, (sum of sizes of descendants of it) /1024/1024) of folders of folder "D:\")
I need to have a better performance, because it sometimes takes until 1min to scan the content.
Because of that I’m trying to filter empty folders or cero size.
I’ve something like this:
((pathnames whose ( it does not contain "Recycle.Bin" ) of it as string, ((sum whose (sum of it as string does not equal "0" ) of sizes of descendants of it) /1024/1024)as string & "MB") of folders of folder "D:\")
It code doesn’t work.
I also try with:
((pathnames whose ( it does not contain "Recycle.Bin" AND (((sum of sizes of descendants of folders of folder it)/1024/1024) does not equal 0 ) ) of it as string, ((sum of sizes of descendants of it) /1024/1024)as string & "MB") of folders of folder "D:\")
If my understanding of your issue is correct I do not think that filtering out empty folders will improve the speed of your query.
The cost of gathering the size of an empty folder to see if you should exclude it is the same as the cost of gathering the size of an empty folder and adding it to your sum.
The performance penalty isn’t due to the number of empty folders you have – it’ll be due to the number of files covered by the query.
Overall this is just going to be a slow query due to the potential number of files you are hitting on the disk.
That being said – if you really just want to filter out empty folders you can do this…
(((pathnames whose ( it does not contain "Recycle.Bin" ) of it, (sum of sizes of descendants of it) /1024/1024) of folders of folder "D:\")) whose (item 1 of it != 0)
adding a filter –
item 1 of it !=0
Will not show any folders that have a reported descendant size of 0
@strawgate is correct that this query is going to be slow no matter what.
What is it that you are trying to accomplish with this query? There might be some better ways to optimize this depending on what you are trying to achieve. For instance, could all files under a certain size be ignored?
One of the first problems you have is that you are not actually excluding things in the Recycle bin. You are only excluding them in the report of the pathnames of the files.
This should be slightly faster:
(pathnames of it, sum of sizes whose(it > 4096) of descendants of it) of folders whose(name of it as lowercase does not end with "recycle.bin") of folders "D:"
This is still a bad idea and I would not recommend it.
Also, you CANNOT use this in Fixlet/Task relevance. You should ONLY use this in an analysis property with a report time of once per 12 hours or less often.
One huge issue with this query is it is impossible to predict how long this will take. It could take a VERY long time on some systems. You would probably be better off running something on the command line to generate a report on a periodic basis and then read that report with relevance.
The analysis needs to display
The content of the first folder and the first level of content, I mean Folder 1a and FileA. Also I should show the size of folder2 and its content, Folder 3 should be no shown.
As I’m not very familiar with relevance I’m trying to go step by step.
Also I would think that a better approach could be run a vbs script via fixlet on the endpoints that outputs the result to a file and the use an analysis to get the result, but I just wanted to avoid to run a fixlet.
What if the total size of a folder and all of it’s contents are less than 1MB? Can that be ignored, or do you want that to be included?
Try this:
(pathnames of it, sum of sizes whose(it > 4096) of descendants of it) whose( item 1 of it > (1024*1024) ) of folders whose(name of it as lowercase does not end with "recycle.bin") of folders "D:"
(item 0 of it, (it as string & " MB") of ( (significant digits 2 of item 1 of it) / (1024*1024) ) ) of (pathname of it, sum of sizes whose(it > 4096) of descendants of it) whose( item 1 of it > (1800000) ) of folders whose(name of it as lowercase does not end with "recycle.bin") of folders "D:"
This is because you are accessing all files in those folders. If any file has a filename that contains unicode or other odd characters, you will get this error.
Good to know. So this approach is useless.
I don’t understand why IEM relevance can provide a suitable way to work with it, we have to use external options in order to get the information.
Also I check directly with IEM Support and they don’t provide support for custom content.
(item 0 of it, (it as string & " MB") of ( (significant digits 2 of item 1 of it) / (1024*1024) ) ) of (pathname of it | "<Error>", sum of sizes whose(it > 4096) of descendants whose(exists name of it) of it) whose( item 1 of it > (1800000) ) of folders whose(exists pathname of it AND name of it as lowercase does not end with "recycle.bin") of folders "D:"