Searching for files by attributes

R

Ray

When I use Vista's "advanced search" function, I can specify location,
date, size, name, tags, and author. Is there any way to search by file
attributes, e.g., to find all files with the archive bit set?
 
K

Keith Miller \(MVP\)

Hmmm....After some testing, it seems the easiest way is to use the command
prompt:

dir /aa (for archive bit)

In Search, I tried various combinations of attribute:A, attribute:="A",
attributes:~"A" etc. with no luck. I then took a more general search (all
files in a specified folder) and then used the 'Attributes' column header to
filter the view -- I used the 'R' attribute, since almost every file has the
Archive attribute set. I then saved the saved the Search & opened the saved
Search in Notepad (saved Searches are XML files). Amidst the other info,
here is the essential part:

<condition
type="leafCondition"
property="System.FileAttributes"
propertyType="uint32"
operator="eq"
value="17"><attributes/>
</condition>

So, if I want to search for files & folders with the read-only attribute
set, I need to type:

system.fileattributes:(17 OR 1)

NOT VERY INTUITIVE, EHHH?!?!?!?

An internet search for 'system.fileattributes' yielded the following
reference for the numeric value of the various attributes:

http://msdn2.microsoft.com/en-us/library/aa365740(VS.85).aspx

So for occasional searching, I would use the command prompt or add the
attributes column & filter on that column. If you need to regularly
manipulate files based on attributes, you might want to check out
PowerShell:

http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx
 
R

Ray

Keith Miller \(MVP\) said:
Hmmm....After some testing, it seems the easiest way is to use the
command prompt:

dir /aa (for archive bit)

I agree that's the easiest way.
In Search, I tried various combinations of attribute:A,
attribute:="A", attributes:~"A" etc. with no luck. I then took a
more general search (all files in a specified folder) and then
used the 'Attributes' column header to filter the view -- I used
the 'R' attribute, since almost every file has the Archive
attribute set. I then saved the saved the Search & opened the
saved Search in Notepad (saved Searches are XML files). Amidst
the other info, here is the essential part:

<condition
type="leafCondition"
property="System.FileAttributes"
propertyType="uint32"
operator="eq"
value="17"><attributes/>
</condition>

So, if I want to search for files & folders with the read-only
attribute set, I need to type:

system.fileattributes:(17 OR 1)

NOT VERY INTUITIVE, EHHH?!?!?!?

Not terribly, but it's a little simpler for my case; the value is just
32.
An internet search for 'system.fileattributes' yielded the
following reference for the numeric value of the various
attributes:

http://msdn2.microsoft.com/en-us/library/aa365740(VS.85).aspx

So for occasional searching, I would use the command prompt or add
the attributes column & filter on that column.

Excellent ideas. I have the attributes column on anyway, but a saved
search makes it simpler, especially since I would also want to limit by
file type.
If you need to
regularly manipulate files based on attributes, you might want to
check out PowerShell:

http://www.microsoft.com/windowsserver2003/technologies/management/
powershell/default.mspx

It's not something I do very often, so another program would be
overkill. Thanks for all the good info.
 
K

Keith Miller \(MVP\)

Ray said:
Not terribly, but it's a little simpler for my case; the value is just
32.

As long as you're only searching for FILES with ONLY the archive attribute
set. That will not find folders with the archive attribute or files with
any of the attributes set: RA, HA, SA, etc. You would need the OR
contruction of all possible values with the archive attribute set.

It's not something I do very often, so another program would be
overkill. Thanks for all the good info.

You're welcome.
 
R

Ray

Keith Miller \(MVP\) said:
As long as you're only searching for FILES with ONLY the archive
attribute set. That will not find folders with the archive
attribute or files with any of the attributes set: RA, HA, SA,
etc. You would need the OR contruction of all possible values
with the archive attribute set.

Good point. Fortunately the files in question shouldn't ever have any
other attributes set, and folders aren't of interest.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top