How to list all files on C drive with DIR?

A

agent60182204

Using Command Prompt on Vista...

I wanted to do get a listing of all the files on my drive so that I
could save it to a text file, and do the same again later and
compare. I used the following command:

DIR /s c:\ > list.txt

But I realized there are some issues:

1) It omits hidden and system files.
2) It might omit files belonging to other users.

To tackle #1, I looked at the syntax of DIR. I can use [DIR /ah] to
list hidden files, but then it lists ONLY hidden files. [DIR /ah /
as] lists hidden files and system files, but no others. There seems
to be no "all" type.

It offers a "minus" syntax too, so [DIR /a-h] lists all non-hidden
files. I can get pretty good results by excluding something rare,
like junction points ("L"), using [DIR /a-L] . Is there a better
way? (I know set-theorists are thinking "Use a Union", but it's not
easy because of the formatting...)

For #2, I say "might" because I seem to get inconsistent results on
Vista. If I DIR the whole drive, while logged in as a non-admin user,
I expected that it would not list files belonging to another user.
But it did, sometimes. Even when [DIR c:\users\bob\documents] fails
(presumably because of permissions), [DIR /s c:\] ends up listing
that documents folder!

But when I ran the same DIR from a different non-admin user, it
omitted the listing of that user's files! Why? Also, one user listed
the Admin's files, and the other didn't! And doing the DIR while
logged in as admin DIDN'T list all users' files!

One possible explanation: On Vista, when I'm logged in as admin, and
using Windows Explorer, if I navigate to another user's documents
folder, it asks me (once only, I think) whether I want to get
permission. If I say yes, it takes about 1 minute to process, and
then gives me access. I guess it changes the permissions on all
files. Does this explain why DIR would omit some items? Is it just
that I never navigated there in Explorer?

I wouldn't mind getting this straight: On Vista, is a non-admin user
allowed to see any other user's files (by exploring c:\users)? Does
it matter if the other user is admin or not? I think the answer for
me has been sometimes yes, sometimes no.

If someone could help clarify these issues, I would appreciate it.
(It's possible that some of my observations above are incorrect. I
tried so many things that I may have mistaken something.)

Still, maybe DIR just isn't the right tool to use. I hope I can use
it, because it's built-in, and works well for my purposes otherwise.
Is ATTRIB any better? Is there some 3rd-party tool I can use?

Thanks

It's off-topic, but if you want to know why I'm saving this DIR, it's
because I noticed that when Norton did a full system scan, it scanned
200,000 files, then a month later it was 400,000, and another month
later it was 800,000. I realize that the number of files it scans can
be more than the number of files on the drive, because it scans files
within compressed files, while it can be less because it only scans
"executable" files. Also, if it chooses to scan files 4 times, it's
none of my business. :) I guess Norton didn't actually say that the
number of files on my drive increased that much. The DIR, although it
was flawed, seems to say that I have about 200,000 files. Anyway.
 
S

smlunatick

Using Command Prompt on Vista...

I wanted to do get a listing of all the files on my drive so that I
could save it to a text file, and do the same again later and
compare.  I used the following command:

DIR /s c:\ > list.txt

But I realized there are some issues:

1) It omits hidden and system files.
2) It might omit files belonging to other users.

To tackle #1, I looked at the syntax of DIR.  I can use  [DIR /ah]  to
list hidden files, but then it lists ONLY hidden files.  [DIR /ah /
as]  lists hidden files and system files, but no others.  There seems
to be no "all" type.

It offers a "minus" syntax too, so  [DIR /a-h]  lists all non-hidden
files.  I can get pretty good results by excluding something rare,
like junction points ("L"), using  [DIR /a-L]  .  Is there a better
way?  (I know set-theorists are thinking "Use a Union", but it's not
easy because of the formatting...)

For #2, I say "might" because I seem to get inconsistent results on
Vista.  If I DIR the whole drive, while logged in as a non-admin user,
I expected that it would not list files belonging to another user.
But it did, sometimes.  Even when  [DIR c:\users\bob\documents]  fails
(presumably because of permissions),  [DIR /s c:\]  ends up listing
that documents folder!

But when I ran the same  DIR  from a different non-admin user, it
omitted the listing of that user's files! Why?  Also, one user listed
the Admin's files, and the other didn't!  And doing the DIR while
logged in as admin DIDN'T list all users' files!

One possible explanation:  On Vista, when I'm logged in as admin, and
using Windows Explorer, if I navigate to another user's documents
folder, it asks me (once only, I think) whether I want to get
permission.  If I say yes, it takes about 1 minute to process, and
then gives me access.  I guess it changes the permissions on all
files.  Does this explain why DIR would omit some items?  Is it just
that I never navigated there in Explorer?

I wouldn't mind getting this straight:  On Vista, is a non-admin user
allowed to see any other user's files (by exploring c:\users)?  Does
it matter if the other user is admin or not?  I think the answer for
me has been sometimes yes, sometimes no.

If someone could help clarify these issues, I would appreciate it.
(It's possible that some of my observations above are incorrect.  I
tried so many things that I may have mistaken something.)

Still, maybe DIR just isn't the right tool to use.  I hope I can use
it, because it's built-in, and works well for my purposes otherwise.
Is ATTRIB any better?  Is there some 3rd-party tool I can use?

Thanks

It's off-topic, but if you want to know why I'm saving this DIR, it's
because I noticed that when Norton did a full system scan, it scanned
200,000 files, then a month later it was 400,000, and another month
later it was 800,000.  I realize that the number of files it scans can
be more than the number of files on the drive, because it scans files
within compressed files, while it can be less because it only scans
"executable" files.  Also, if it chooses to scan files 4 times, it's
none of my business.  :)  I guess Norton didn't actually say that the
number of files on my drive increased that much.  The DIR, although it
was flawed, seems to say that I have about 200,000 files.  Anyway.

I found this:

http://renegademinds.com/TipsTricks/Dumpfileanddirectoryliststotextfiles/tabid/56/Default.aspx
 
P

Pegasus \(MVP\)

Using Command Prompt on Vista...

I wanted to do get a listing of all the files on my drive so that I
could save it to a text file, and do the same again later and
compare. I used the following command:

DIR /s c:\ > list.txt

But I realized there are some issues:

1) It omits hidden and system files.
2) It might omit files belonging to other users.

To tackle #1, I looked at the syntax of DIR. I can use [DIR /ah] to
list hidden files, but then it lists ONLY hidden files. [DIR /ah /
as] lists hidden files and system files, but no others. There seems
to be no "all" type.

It offers a "minus" syntax too, so [DIR /a-h] lists all non-hidden
files. I can get pretty good results by excluding something rare,
like junction points ("L"), using [DIR /a-L] . Is there a better
way? (I know set-theorists are thinking "Use a Union", but it's not
easy because of the formatting...)

For #2, I say "might" because I seem to get inconsistent results on
Vista. If I DIR the whole drive, while logged in as a non-admin user,
I expected that it would not list files belonging to another user.
But it did, sometimes. Even when [DIR c:\users\bob\documents] fails
(presumably because of permissions), [DIR /s c:\] ends up listing
that documents folder!

But when I ran the same DIR from a different non-admin user, it
omitted the listing of that user's files! Why? Also, one user listed
the Admin's files, and the other didn't! And doing the DIR while
logged in as admin DIDN'T list all users' files!

One possible explanation: On Vista, when I'm logged in as admin, and
using Windows Explorer, if I navigate to another user's documents
folder, it asks me (once only, I think) whether I want to get
permission. If I say yes, it takes about 1 minute to process, and
then gives me access. I guess it changes the permissions on all
files. Does this explain why DIR would omit some items? Is it just
that I never navigated there in Explorer?

I wouldn't mind getting this straight: On Vista, is a non-admin user
allowed to see any other user's files (by exploring c:\users)? Does
it matter if the other user is admin or not? I think the answer for
me has been sometimes yes, sometimes no.

If someone could help clarify these issues, I would appreciate it.
(It's possible that some of my observations above are incorrect. I
tried so many things that I may have mistaken something.)

Still, maybe DIR just isn't the right tool to use. I hope I can use
it, because it's built-in, and works well for my purposes otherwise.
Is ATTRIB any better? Is there some 3rd-party tool I can use?

Thanks

It's off-topic, but if you want to know why I'm saving this DIR, it's
because I noticed that when Norton did a full system scan, it scanned
200,000 files, then a month later it was 400,000, and another month
later it was 800,000. I realize that the number of files it scans can
be more than the number of files on the drive, because it scans files
within compressed files, while it can be less because it only scans
"executable" files. Also, if it chooses to scan files 4 times, it's
none of my business. :) I guess Norton didn't actually say that the
number of files on my drive increased that much. The DIR, although it
was flawed, seems to say that I have about 200,000 files. Anyway.

Under WinXP you can resolve this issue by logging on as Administrator and
running this command:
attrib /s c:\*.*
Under Vista it's probably the same - best to repost in a Vista newsgroup.
 
A

agent60182204

Thanks guys.
smlunatick, your link taught me that dir/a displays all files.
That wasn't so clear in the help.

Pegasus, your attrib command does what I want, thanks. It's a
different output format than DIR, with the full path on each line.
But that's ok, maybe even better. The diff can be done without
context now, ie just show differing lines. OTOH, the file will be a
lot bigger, and the file-size isn't shown, for cases when files grow.

I'm still wondering why, when I did DIR as admin, it didn't list all
files. I'll have to test if the same thing happens to ATTRIB.
 
P

Pegasus \(MVP\)

Thanks guys.
smlunatick, your link taught me that dir/a displays all files.
That wasn't so clear in the help.

Pegasus, your attrib command does what I want, thanks. It's a
different output format than DIR, with the full path on each line.
But that's ok, maybe even better. The diff can be done without
context now, ie just show differing lines. OTOH, the file will be a
lot bigger, and the file-size isn't shown, for cases when files grow.

I'm still wondering why, when I did DIR as admin, it didn't list all
files. I'll have to test if the same thing happens to ATTRIB.

You can use smlunatick's suggestion while maintaining AND get the full path
details:
dir /s /a /b c:\*.*
 
A

agent60182204

Pegasus: Thanks. You know, I don't think I've ever tried dir /b
combined with /s , so only within one folder. Then it just lists
the filename. So I just assumed that it would do the same if used
with /s . I shouldn't assume...
 
A

agent60182204

Maybe people are not addressing the user-account issue because I
mentioned Vista, while this is an XP group. I tested it also on XP.
Some background...

I have 3 accounts. AA is the first account I created, an admin. BB
is also an admin. And CC is a non-admin.

Is AA "more special" than BB? I read once about the "hidden
Administrator" account. From what I recall, it's called
"Administrator", and you can get to it by starting in Safe Mode. I
used it once when I couldn't log into my other accounts. Anyway, is
AA equal to that account? Or are AA and BB equivalent in their
"power"?

Anyway, I ran a [dir /s > list.txt] while sitting in the c:\
folder, and I tried this while logged into each of my 3 accounts.

The results: AA's list listed files from all 3 users. CC's list
listed only CC's files. (So far it makes sense.) BB's list listed
files from BB and CC, but not AA. Why?

Windows Explorer is consistent with this. If BB tries to click on
C:\Documents and Settings\AA
it blocks it.

I don't have a practical problem here, as I can just run DIR from AA.
I'm just wondering. Maybe something from your answer will help sort
out what happened to me in Vista. On Vista, I do have a practical
problem, as no user's DIR gives a complete list.

I posted my question also to
microsoft.public.windows.vista.general , btw.

Thanks
 
P

Pegasus \(MVP\)

Maybe people are not addressing the user-account issue because I
mentioned Vista, while this is an XP group. I tested it also on XP.
Some background...

I have 3 accounts. AA is the first account I created, an admin. BB
is also an admin. And CC is a non-admin.

Is AA "more special" than BB? I read once about the "hidden
Administrator" account. From what I recall, it's called
"Administrator", and you can get to it by starting in Safe Mode. I
used it once when I couldn't log into my other accounts. Anyway, is
AA equal to that account? Or are AA and BB equivalent in their
"power"?

Anyway, I ran a [dir /s > list.txt] while sitting in the c:\
folder, and I tried this while logged into each of my 3 accounts.

The results: AA's list listed files from all 3 users. CC's list
listed only CC's files. (So far it makes sense.) BB's list listed
files from BB and CC, but not AA. Why?

Windows Explorer is consistent with this. If BB tries to click on
C:\Documents and Settings\AA
it blocks it.

I don't have a practical problem here, as I can just run DIR from AA.
I'm just wondering. Maybe something from your answer will help sort
out what happened to me in Vista. On Vista, I do have a practical
problem, as no user's DIR gives a complete list.

I posted my question also to
microsoft.public.windows.vista.general , btw.

Thanks

I addressed the user-account issue in my first reply by suggesting that you
log on as administrator. This would certainly work under WinXP. If it fails
to work under Vista then this strengthens my recommendation that you should
post Vista questions in a Vista newsgroup right from the start.
 
A

agent60182204

I just reread my last post, and I now realize that I wasn't clear. I
actually tested this on XP and I obtained an unexpected result. The
AA,BB,CC stuff was all tested on XP. The unexpected result was that
the listing from BB wasn't a full listing.

I wouldn't be so quick to assume there's a "bug in Windows".
Probably, I have a misunderstanding of how things are supposed to
work.

While it's true that I am currently doing listings to deal with a
specific problem I have on a Vista computer, I do also work on an XP
computer regularly. Besides, I like to know how things work. :)

I admit that the knowledge I gain from resolving this XP issue will
probably help me sort out the Vista issue, since many of these
"security policies" are surely similar on the 2 versions, but let's
just deal with the XP issue, and that will be fine.

---
Ok, please reread my previous post.

Now, if you can see the problem without testing, great. Otherwise,
you may not have to do DIRs to see the assymetry. If I log in as AA,
I can navigate in Windows Explorer to C:\Documents and Settings
\BB . But if I am logged in as BB, I cannot navigate to C:
\Documents and Settings\AA. AA and BB are admins. Can you explain
this?

If you have 2 admin accounts on your computer, do you get the same
result? If not, can you explain why I have this assymetry? I don't
remember if I once requested access, or changed some setting years
ago. Is there any such setting?

Like I said at the end of the last post, I do have a workaround on
XP. I can just use the AA account. If you are not interested in
having a theoretical discussion, don't feel any compulsion to discuss
further. :)

Thanks
 
P

Pegasus \(MVP\)

I just reread my last post, and I now realize that I wasn't clear. I
actually tested this on XP and I obtained an unexpected result. The
AA,BB,CC stuff was all tested on XP. The unexpected result was that
the listing from BB wasn't a full listing.

I wouldn't be so quick to assume there's a "bug in Windows".
Probably, I have a misunderstanding of how things are supposed to
work.

While it's true that I am currently doing listings to deal with a
specific problem I have on a Vista computer, I do also work on an XP
computer regularly. Besides, I like to know how things work. :)

I admit that the knowledge I gain from resolving this XP issue will
probably help me sort out the Vista issue, since many of these
"security policies" are surely similar on the 2 versions, but let's
just deal with the XP issue, and that will be fine.

---
Ok, please reread my previous post.

Now, if you can see the problem without testing, great. Otherwise,
you may not have to do DIRs to see the assymetry. If I log in as AA,
I can navigate in Windows Explorer to C:\Documents and Settings
\BB . But if I am logged in as BB, I cannot navigate to C:
\Documents and Settings\AA. AA and BB are admins. Can you explain
this?

If you have 2 admin accounts on your computer, do you get the same
result? If not, can you explain why I have this assymetry? I don't
remember if I once requested access, or changed some setting years
ago. Is there any such setting?

Like I said at the end of the last post, I do have a workaround on
XP. I can just use the AA account. If you are not interested in
having a theoretical discussion, don't feel any compulsion to discuss
further. :)

Thanks

By default an administrator has full access to all user files and folders.
However, it is quite easy to set folder permissions that prevent an
administrator from accessing them. If you think that your "dir" command does
not show all files and folders then you need to examine the permissions and
ownerships for these files and folders. Click Start / Help and look for help
on "Permissions" and also "Ownership" if unsure how it's done. And yes, I
fully agree with you: There are no bugs in this area of Windows. If there
were then we would have known about them a long time ago.
 
J

Jim

On Thu, 20 Nov 2008 05:34:09 -0800 (PST),
Using Command Prompt on Vista...

I wanted to do get a listing of all the files on my drive so that I
could save it to a text file, and do the same again later and
compare. I used the following command:

DIR /s c:\ > list.txt

But I realized there are some issues:

1) It omits hidden and system files.
2) It might omit files belonging to other users.

To tackle #1, I looked at the syntax of DIR. I can use [DIR /ah] to
list hidden files, but then it lists ONLY hidden files. [DIR /ah /
as] lists hidden files and system files, but no others. There seems
to be no "all" type.

It offers a "minus" syntax too, so [DIR /a-h] lists all non-hidden
files. I can get pretty good results by excluding something rare,
like junction points ("L"), using [DIR /a-L] . Is there a better
way? (I know set-theorists are thinking "Use a Union", but it's not
easy because of the formatting...)

For #2, I say "might" because I seem to get inconsistent results on
Vista. If I DIR the whole drive, while logged in as a non-admin user,
I expected that it would not list files belonging to another user.
But it did, sometimes. Even when [DIR c:\users\bob\documents] fails
(presumably because of permissions), [DIR /s c:\] ends up listing
that documents folder!

But when I ran the same DIR from a different non-admin user, it
omitted the listing of that user's files! Why? Also, one user listed
the Admin's files, and the other didn't! And doing the DIR while
logged in as admin DIDN'T list all users' files!

One possible explanation: On Vista, when I'm logged in as admin, and
using Windows Explorer, if I navigate to another user's documents
folder, it asks me (once only, I think) whether I want to get
permission. If I say yes, it takes about 1 minute to process, and
then gives me access. I guess it changes the permissions on all
files. Does this explain why DIR would omit some items? Is it just
that I never navigated there in Explorer?

I wouldn't mind getting this straight: On Vista, is a non-admin user
allowed to see any other user's files (by exploring c:\users)? Does
it matter if the other user is admin or not? I think the answer for
me has been sometimes yes, sometimes no.

If someone could help clarify these issues, I would appreciate it.
(It's possible that some of my observations above are incorrect. I
tried so many things that I may have mistaken something.)

Still, maybe DIR just isn't the right tool to use. I hope I can use
it, because it's built-in, and works well for my purposes otherwise.
Is ATTRIB any better? Is there some 3rd-party tool I can use?

Thanks

It's off-topic, but if you want to know why I'm saving this DIR, it's
because I noticed that when Norton did a full system scan, it scanned
200,000 files, then a month later it was 400,000, and another month
later it was 800,000. I realize that the number of files it scans can
be more than the number of files on the drive, because it scans files
within compressed files, while it can be less because it only scans
"executable" files. Also, if it chooses to scan files 4 times, it's
none of my business. :) I guess Norton didn't actually say that the
number of files on my drive increased that much. The DIR, although it
was flawed, seems to say that I have about 200,000 files. Anyway.

Karenware`s Directory printer .
 
A

agent60182204

Ok, I read up on permissions, and I checked on my computer. On my XP
computer, I have "Simple File Sharing" on, so I don't have the fine-
grained security settings (but I did see them on other computers).
There is, however, one option that you can set. If you look at the
Properties dialog of a folder, under Sharing, there is one checkbox
called "Make this folder private". I kind of remember checking it a
long time ago, after realizing that any other administrator account
could see my files.

This now explains my result on XP, and, Pegasus, you did correctly
diagnose my problem in your last message.

On Vista, I did the same checking, and I got further clarity on the
issue. Since this is not a Vista group, I won't describe it fully,
but I seem to be a "half-administrator". I don't know how this
happened, or if the results I am seeing make sense, but I asked a
question in the Vista group. If anyone is interested, I posted it
today to the group microsoft.public.windows.vista.general with
title "User account permissions bugs?".


For completeness, I'll throw this in about the "dir /a" syntax, based
on my testing. I hope someone finds it useful:

dir - Shows "normal" files, ie not hidden, etc.
dir/a - Shows all files.
dir/ah - Shows all hidden files, and no others.
dir/as - Shows all system files, and no others.
dir/ahs - Shows all files that are both hidden and system, and no
others.
dir /ah /as - It considers only the last "/a", so equivalent to "dir/
as".
- So there is no way to list all files that are either hidden or
system.
dir/ah-s - Shows all files that are hidden and NOT system.
- There are more properties than H and S, and they can be used in the
same way.

I also discovered that there is good help in the Windows Help on all
command-line commands. This gives a bit more info than eg "dir/?" ,
and it's nicer to have the help in a separate window, with markup.
Oh, I just noticed that the help for DIR fully explains what I wrote
above.

Open Windows Help (Start-Help), search for "Command Line Reference".
The A-Z page has every command listed, with syntax!

Also, it lists all commands, and there were some that I didn't know
existed! fc seems to be a reasonably good "diff". "findstr" seems to
be a good "grep". I keep finding these EXE files under c:\windows and
system32 that I never realized were there! I never heard about "net
user" and "netsh" until I had a problem and googled. Commands like
"reg" and "sc" are good to know about, although GUI equivalents are
usually ok.

And robocopy.exe is just sitting there in system32. It's included by
default in Vista, and (apparently) in the Resource Kit for XP. It's
pretty powerful for copying folders around. Tons of options, and it
will retry if the network link breaks.

I wish that when I installed Windows, a document would pop up
describing the new features of Windows, on this level. The Windows
tour is a different level, and the books in the store are mostly on
the same level. I guess there must be stuff on the Net, but I didn't
find it because I didn't know to look for it.

That's the end of my rant.

Thanks again.
 

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