0

I am working on a project which is used to make a list of files of any specific windows path. It traverses all files and folder one by one and make a list. I want to ignore all the MS Windows and MS Product's files. I filtered list of Microsoft Products from NSRL_FILE. But now I do not want to traverse any windows folder or ms product's folders. Does anyone have idea, how can I implement this?

NOTE: I do not want to make list of MS Windows and MS Product's related folder name list to ignore while traversing.

SOLUTION: I found the solution from this forum link, Its returning following details...

CompanyName = Microsoft Corporation
FileDescription = SQM Client
FileVersion = 10.0.14393.0 (rs1_release.160715-1616)
InternalName = sqmapi
LegalCopyright = © Microsoft Corporation. All rights reserved.
OriginalFilename = sqmapi.dll
ProductName = Microsoft® Windows® Operating System
ProductVersion = 10.0.14393.0
OleSelfRegister = 
Community
  • 1
  • 1
Tej Kiran
  • 2,218
  • 5
  • 21
  • 42
  • Well, you have to know what "MS WIndows or MS Products files" are. Which is not a programming question. – lexicore Dec 14 '16 at 13:05
  • Thanks for reply, you mean, we should make are list of MS Products folder and files as well as for MS Windows and then at the time of traversing, checks it in the list. The end user do not want to select folder one from document folder , one from downloads and one from desktop folder. He wants that he select a parent folder and then application ignore the unwanted files that are related to the Microsoft. We have a list of Microsoft files, we we want same kind of list for folder. – Tej Kiran Dec 14 '16 at 13:26

3 Answers3

1

You're going to have to have a list somewhere of the folder names to ignore. Create a text file with each name to ignore in it. Read the file in from your program and if you find a path that matches one in your file, ignore it. As you find more folders to ignore, you just add them to the list.

Brian Pipa
  • 808
  • 9
  • 23
  • OP says..`I do not want to make list of MS Windows and MS Product's related folder name list to ignore while traversing` – user3437460 Dec 14 '16 at 13:09
  • 1
    I know he says that, but unless there is some webservice or API he can call to get the list, he's going to do it himself. – Brian Pipa Dec 14 '16 at 13:13
  • No you are not getting my point. I want list of such folder, but do not want to prepare is manually. If any site or service provides such kind of list that get uploaded time to time. else user3437460 suggest is also good. – Tej Kiran Dec 14 '16 at 13:31
0

But now I do not want to traverse any windows folder or ms product's folders. Does anyone have idea, how can I implement this?

If you do not want to keep a list of names to skip. The only approach I can think of using Java is to read the meta data from the files.

You can try to read the company attribute from the files' meta data and check whether it matches "Microsoft Corporation".

enter image description here

The checks can also be based on multiple filter criterias, such as file extension.

Java has a class known as BasicFileAttributes where you can use it for this purpose.

Take a look at the documentation here: https://docs.oracle.com/javase/7/docs/api/java/nio/file/attribute/BasicFileAttributes.html

Note: I am not sure whether this will work perfectly, but this gives you an alternative.

user3437460
  • 17,253
  • 15
  • 58
  • 106
  • Thanks for nice suggestion, I will try this. – Tej Kiran Dec 14 '16 at 13:28
  • @TejKiran There are other options, but I think that will cause you more trouble, so this is what you can try. If it helps, you may accept/vote my solution. Thanks. – user3437460 Dec 14 '16 at 13:31
  • Its returns only following details {sun.nio.fs.WindowsFileAttributes@522} fileAttrs = 32 creationTime = 131131430412492635 lastAccessTime = 131131430412492635 lastWriteTime = 131131430412492635 size = 34128 reparseTag = 0 volSerialNumber = 0 fileIndexHigh = 0 fileIndexLow = 0. There is not other attributes details – Tej Kiran Dec 14 '16 at 14:57
0

Building on user3437460’s suggestion, you can examine the owner:

String owner = Files.getOwner(path).getName();
boolean isSystemFile = owner.equals("NT SERVICE\\TrustedInstaller");

It’s far from perfect, but it’s better than nothing.

Tested in Windows 7. I have no idea how this behaves in other Windows versions.

VGR
  • 40,506
  • 4
  • 48
  • 63