Fast search within files in Windows

RPA Asset Store

Fast search within files in Windows

File search is commonly used in automation. But when the file number within the folder is too big the standard search method take very long to complete. A solution to that problem is to use a Windows Search feature.

Windows Search builds a full-text index of files on a computer. Once a file is indexed we can use the index to search results more rapidly than it would take to search through all the files on the computer. Searches are performed on file names, contents of the files, folders, mails and other media on local or remote machines.

We have to know that not all files in Windows are indexed. Indexed folders can be found in Indexing Options. This is the location where we can add other folders to the index.

In order to search remote location we have to ensure the searched location (folder) is added to the index on the target machine.

Example Windows Search queries:

Search files by file names:

SELECT System.ItemName FROM SystemIndex WHERE System.ItemName LIKE '%name%'

Search files by name in folder C:\temp and sub-folders

SELECT System.ItemName FROM SystemIndex WHERE scope ='file:C:/temp' AND System.ItemName LIKE '%name%'

Search files in the folder C:\temp only

SELECT System.ItemName FROM SystemIndex WHERE directory = 'file:C:/temp' AND System.ItemName LIKE '%name%'

Search folder by name

SELECT System.ItemName FROM SystemIndex WHERE System.ItemType = 'Directory' AND System.Itemname LIKE '%name%'

Search remote location

SELECT <columns> FROM [machinename.]SystemIndex [WHERE <conditions>]

Columns of the index :

System.AuthorSystem.Document.CharacterCount
System.CategorySystem.Document.ClientID
System.CommentSystem.Document.Contributor
System.CompanySystem.Document.DateCreated
System.ComputerNameSystem.Document.DatePrinted
System.ContentStatusSystem.Document.DateSaved
System.ContentTypeSystem.Document.Division
System.CopyrightSystem.Document.DocumentID
System.DateAccessedSystem.Document.HiddenSlideCount
System.DateAcquiredSystem.Document.LastAuthor
System.DateArchivedSystem.Document.LineCount
System.DateCompletedSystem.Document.Manager
System.DateCreatedSystem.Document.PageCount
System.DateImportedSystem.Document.ParagraphCount
System.DateModifiedSystem.Document.PresentationFormat
System.DueDateSystem.Document.RevisionNumber
System.EndDateSystem.Document.SlideCount
System.FileAttributesSystem.Document.TotalEditingTime
System.FileDescriptionSystem.Document.WordCount
System.FileExtensionSystem.Document.ByteCount
System.FileNameSystem.Document.CharacterCount
System.FileOwnerSystem.Document.ClientID
System.ItemAuthorsSystem.Document.Contributor
System.ItemDateSystem.Document.DateCreated
System.ItemFolderNameDisplaySystem.Document.DatePrinted
System.ItemFolderPathDisplaySystem.Document.DateSaved
System.ItemFolderPathDisplayNarrowSystem.Document.Division
System.ItemNameSystem.Document.DocumentID
System.ItemNameDisplaySystem.Document.HiddenSlideCount
System.ItemNamePrefixSystem.Document.LastAuthor
System.ItemParticipantsSystem.Document.LineCount
System.ItemPathDisplaySystem.Document.Manager
System.ItemPathDisplayNarrowSystem.Document.PageCount
System.ItemTypeSystem.Document.ParagraphCount
System.ItemTypeTextSystem.Document.PresentationFormat
System.ItemUrlSystem.Document.RevisionNumber
System.KeywordsSystem.Document.SlideCount
System.KindSystem.Document.TotalEditingTime
System.SourceItemSystem.Document.WordCount
System.StartDateSystem.Search.AutoSummary
System.StatusSystem.Search.Contents
System.SubjectSystem.Search.EntryID
System.ThumbnailCacheIdSystem.Search.GatherTime
System.TitleSystem.Search.Rank
System.Document.ByteCountSystem.Search.Store

To simplify using Windows Search we have created a Blue Prism VBO that can be downloaded here.