1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to? Problem with "For /R ..."

Discussion in 'Support' started by mathewsdw, Jan 31, 2012.

  1. mathewsdw

    Joined:
    May 24, 2010
    Messages:
    855
    Likes Received:
    0
    First off as background I believe I've mentioned on this forum in the past that the partitions of the internal hard drive on this laptop are very full (99.5 % in use or the C: partition as of this moment, 98 % in use for the D: partition) which has, not particularly surprisingly, become somewhat more than a "bit of a problem", so in an effort to figure out what is taking so much space on these drives I entered the following (series of) command(s):
    Code:
    (Timer On & (For /R C:\ /D %Dir in (*) Do (Echo %@Format[14,%@Comma[%@FileSize
    ["%Dir",b,a]]] %@Format[6,%@Comma[%@Files["%Dir"]]]    %Dir & Echo %@Format[14,%@Co
    mma[%@FileSize[/S "%Dir",b,a]]] %@Format[6,%@Comma[%@Files[/S "%Dir"]]] /S %Dir) |
    Sort /R) & Timer Off) | List
    
    The final intent of which being that I hit the "Ins[ert]" key on my keyboard while looking at the resulting output (list) to save it. (There are two lines output for each directory, the first being the information for that directory alone and the second being the information for that directory and its subdirectories. The "Timer" commands are so I can see, just out of curiosity, how long the whole thing takes for each drive.)

    But when I did this, I got some initially very surprising numbers, which, when I thought about it a little bit were not really all that surprising at all. That is because I use both symbolic and hard links on a regular basis because of my bad memory so that I can quickly find a file wherever at that moment I think it might be (if I think that it's going to be there it will be there! :)), and in one particular "class" of situations exactly the same group of (very large!) files might show up four or even five times. Well I really doubt that there is a solution for hard links (a relatively minor problem that I'm willing to ignore), but I'm wonder if there's some way to make "For /R xxxx /D %Dir in" not "follow" directories that are symbolic links (or junctions, of course).

    Now I do have a "solution" in mind that can eliminate the problem entirely (based on using "PDir" to identify files with duplicate-INODEs and therefore be excluded, but said solution isn't exactly trivial (at least for me!) and given my slowness could take quite a while to achieve, so I'm hoping there's a quicker way.

    Any suggestions anybody can give me in this matter would be appreciated.

    - Dan
     
  2. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,726
    Likes Received:
    80
    Use the /Nj (no junctions) option in FOR.
     
  3. mathewsdw

    Joined:
    May 24, 2010
    Messages:
    855
    Likes Received:
    0
    Thank you, Rex! I should have known that if I need to do it you have provided a way! :) (My eyesight makes "accurately" reading the docs somewhat difficult; if I have no prior expectations that I will see something sadly I won't.)

    Rex, I spoke too soon. Look at the following transcript where I tried every way I could think of (I also, just for the heck of it, tried putting a colon between the "N" and "j" (ala "/N:j") and that didn't work either which didn't at all surprise me.) So:
    Code:
      Tue  Jan 31, 2012  3:57:02p
     
    ISO8601 plugin v1.1.1 loaded.
    SafeChars plugin v1.6.1 loaded.
    Sift v0.55.0 loaded.
     
    TCC  12.11.76  Windows 7 [Version 6.1.7601]
    Copyright 2011  Rex Conn & JP Software Inc.  All Rights Reserved
    Registered to Daniel Mathews
     
    [Z:\]For /Nj /R D:\ /D %Dir in (*) Do (Echo %@Format[14,%@Comma[%@FileSize["%Dir",b
    ,a]]] %@Format[6,%@Comma[%@Files["%Dir"]]]    %Dir & Echo %@Format[14,%@Comma[%@Fil
    eSize[/S "%Dir",b,a]]] %@Format[6,%@Comma[%@Files[/S "%Dir"]]] /S %Dir) | Sort /R |
    List
    TCC: (Sys) The parameter is incorrect.
    "j"
    Usage : FOR [/A:[[-][+]rhsdaecjot] /D /F ["options"] /H /I"text" /L /Nj /O:[-]adegn
    rstu /R [path] /T"..." /W] %var IN ([@]set | start, step, end) [DO] command ...
    ^C
    [Z:\]For /R D:\ /D /Nj %Dir in (*) Do (Echo %@Format[14,%@Comma[%@FileSize["%Dir",b
    ,a]]] %@Format[6,%@Comma[%@Files["%Dir"]]]    %Dir & Echo %@Format[14,%@Comma[%@Fil
    eSize[/S "%Dir",b,a]]] %@Format[6,%@Comma[%@Files[/S "%Dir"]]] /S %Dir) | Sort /R |
    List
    TCC: (Sys) The parameter is incorrect.
    "j"
    Usage : FOR [/A:[[-][+]rhsdaecjot] /D /F ["options"] /H /I"text" /L /Nj /O:[-]adegn
    rstu /R [path] /T"..." /W] %var IN ([@]set | start, step, end) [DO] command ...
    TCC: (Sys) The parameter is incorrect.
    "j"
    Usage : FOR [/A:[[-][+]rhsdaecjot] /D /F ["options"] /H /I"text" /L /Nj /O:[-]adegn
    rstu /R [path] /T"..." /W] %var IN ([@]set | start, step, end) [DO] command ...
    TCC: (Sys) The parameter is incorrect.
    "j"
    Usage : FOR [/A:[[-][+]rhsdaecjot] /D /F ["options"] /H /I"text" /L /Nj /O:[-]adegn
    rstu /R [path] /T"..." /W] %var IN ([@]set | start, step, end) [DO] command ...
    TCC: (Sys) The parameter is incorrect.
    "j"
    Usage : FOR [/A:[[-][+]rhsdaecjot] /D /F ["options"] /H /I"text" /L /Nj /O:[-]adegn
    rstu /R [path] /T"..." /W] %var IN ([@]set | start, step, end) [DO] command ...
    TCC: (Sys) The parameter is incorrect.
    "j"
     
    ...
     
    ^C
    [D:\]For /R D:\ /D %Dir /Nj in (*) Do (Echo %@Format[14,%@Comma[%@FileSize["%Dir",b
    ,a]]] %@Format[6,%@Comma[%@Files["%Dir"]]]    %Dir & Echo %@Format[14,%@Comma[%@Fil
    eSize[/S "%Dir",b,a]]] %@Format[6,%@Comma[%@Files[/S "%Dir"]]] /S %Dir) | Sort /R |
    List
    TCC: (Sys) The parameter is incorrect.
    "j"
    Usage : FOR [/A:[[-][+]rhsdaecjot] /D /F ["options"] /H /I"text" /L /Nj /O:[-]adegn
    rstu /R [path] /T"..." /W] %var IN ([@]set | start, step, end) [DO] command ...
    TCC: (Sys) The parameter is incorrect.
    "j"
    Usage : FOR [/A:[[-][+]rhsdaecjot] /D /F ["options"] /H /I"text" /L /Nj /O:[-]adegn
    rstu /R [path] /T"..." /W] %var IN ([@]set | start, step, end) [DO] command ...
    TCC: (Sys) The parameter is incorrect.
    "j"
     
    ...
     
    ^C
    [D:\]For /R D:\ /D %Dir in (*) Do (Echo %@Format[14,%@Comma[%@FileSize["%Dir",b,a]]
    ] %@Format[6,%@Comma[%@Files["%Dir"]]]    %Dir & Echo %@Format[14,%@Comma[%@FileSiz
    e[/S "%Dir",b,a]]] %@Format[6,%@Comma[%@Files[/S "%Dir"]]] /S %Dir) | Sort /R | Lis
    t
    ^C
    [D:\]
    
    In the last case (with no "/Nj" parameter) i waited about a minute before hitting ^C. Also that is exactly the same command as the one that I was running in the first place that (mostly!) worked so I absolutely knew that it would work in the first place.

    While I certainly may be doing something wrong here, I can't figure out what it might be.

    - Dan
     

Share This Page