Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Fixed what's the exact meaning of /Sn?

May
313
6
I wrote in the feedback to ask for "dir /S /M0" option to to show only one footer at the end.
I started experimenting with "dir /Sn" and I am not sure if it works as it should (WAD? BUG?).
On my C: drive I created a test directory, I moved into it so now it is my current working directory, and from there I created a directory tree with "md /S a\b\c".
Now, if I type "dir /S0" it is the same as "dir /S". It shows everything. Instead, I believe that it should stop at the current directory, so in my opinion "dir /S0" should be like a simple "dir".
Second, if I type "dir /S1" it shows

Volume in drive C is unlabeled Serial number is 4717:4a93
Directory of C:\test\*

21/12/2011 10:22 <DIR> .
21/12/2011 10:22 <DIR> ..
21/12/2011 10:22 <DIR> a
0 bytes in 0 files and 3 dirs

Directory of C:\test\a\*

21/12/2011 10:22 <DIR> .
21/12/2011 10:22 <DIR> ..
21/12/2011 10:22 <DIR> b
0 bytes in 0 files and 3 dirs

Total for: C:\test\*
0 bytes in 0 files and 6 dirs 0 bytes allocated
7.411.499.008 bytes free

So, it shows the content of current directory, of 1st level directory a, but it does not show the total for directory a, only the total for current.
If I type dir /S2 it shows the content of current directory, the content of a, the content of b, the total for a, the total for current, but not the total for b.
And so on.
Instead, if I type "dir /S+1" it shows headers and footers in the right way (I did not check if it counts in the correct way).

Volume in drive C is unlabeled Serial number is 4717:4a93

Directory of C:\test\a\*

21/12/2011 10:22 <DIR> .
21/12/2011 10:22 <DIR> ..
21/12/2011 10:22 <DIR> b
0 bytes in 0 files and 3 dirs

Directory of C:\test\a\b\*

21/12/2011 10:22 <DIR> .
21/12/2011 10:22 <DIR> ..
21/12/2011 10:22 <DIR> c
0 bytes in 0 files and 3 dirs

Directory of C:\test\a\b\c\*

21/12/2011 10:22 <DIR> .
21/12/2011 10:22 <DIR> ..
0 bytes in 0 files and 2 dirs

Total for: C:\test\a\b\c\*
0 bytes in 0 files and 2 dirs 0 bytes allocated

Total for: C:\test\a\b\*
0 bytes in 0 files and 5 dirs 0 bytes allocated

Total for: C:\test\a\*
0 bytes in 0 files and 8 dirs 0 bytes allocated
7.411.499.008 bytes free

Also, "dir /S+0" work as I expect.

So, it seems to me that "dir /S+n" works, "dir /Sn" has some issues.
Can You check this?

Thank You very much again and regards

Rodolfo Giovanninetti
 
I wrote in the feedback to ask for "dir /S /M0" option to to show only one footer at the end.
I started experimenting with "dir /Sn" and I am not sure if it works as it should (WAD? BUG?).
I just saw that in the help it says

If you specify a + followed by a number after the /S, DIR will not display any filenames until it gets to that depth in the subdirectory tree. For example, if you have a directory tree \a\b\c\d\e, /S+2 will not display the contents of \a or \a\b.

Instead, in my case, /S+2 shows the content of \a\b. BUT, this is the behaviour that I like. So, please do not change the behaviour of /S+n, instead change the documentation.
And change the behaviour of /Sn.
In my opinion, the current directory "C:\test" is the level 0.
Inside it, a is level 1, b is level 2, c is level 3 and so on.
So, if I am inside C:\test:
the command "dir /S0" should work as a simple "dir": header for test, content of test, footer of test.
the command "dir /S1" should show: header for test, content of test, header for a, content of a, footer for a, footer for test.
The command "dir /S+0" or "dir /S+1" work as I want.

Thank You very much again and regards

Rodolfo Giovanninetti
 
I type also "del /S+2 *.txt" and it did not delete anything (I had created a .txt file in each directory level), whereas "del /S2 *.txt" deleted inside current and two levels below, so in this case /Sn seems to work, and /S+n not.
So, I believe that I missed something important about /S[+]n, or that You should check the code that handle this part.

Thank You very much again and regards

Rodolfo Giovanninetti
 
I wrote in the feedback to ask for "dir /S /M0" option to to show only one footer at the end.
I started experimenting with "dir /Sn" and I am not sure if it works as it should (WAD? BUG?).
On my C: drive I created a test directory, I moved into it so now it is my current working directory, and from there I created a directory tree with "md /S a\b\c".
Now, if I type "dir /S0" it is the same as "dir /S". It shows everything. Instead, I believe that it should stop at the current directory, so in my opinion "dir /S0" should be like a simple "dir".

This is WAD. Since there is no reason to specify /S0, it is treated as a /S with an unrelated additional option tacked on without the (required, but try to get people to actually use it!) switch character.

So, it shows the content of current directory, of 1st level directory a, but it does not show the total for directory a, only the total for current.

From my notes in the code this is also WAD, but the notes are too cryptic for me to recall exactly why it was done this way. I'll have to poke around some more to see if I can recall whether there was a (preferably good) reason for doing this.
 
Back
Top