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

rd/s with symlinks and junctions

Discussion in 'Support' started by kb1001, Mar 24, 2009.

  1. kb1001

    Joined:
    Mar 23, 2009
    Messages:
    7
    Likes Received:
    0
    If I create a symlink (or a junction) to a directory and then do a "rd/s" of that directory, TCC deletes all of the files in the linked directory.

    The rd command in the (Vista) cmd shell merely deletes the symlink, leaving the files in the target directory alone.

    Is there any way to tell TCC to behave the same way?

    TIA,
    Kb
     
  2. Rod Savard

    Joined:
    May 26, 2008
    Messages:
    481
    Likes Received:
    3
    Good suggestion.

    You might be able to set up an RD alias that checks to see if the directory is a junction (perhaps using the @JUNCTION function?). If so it would call MKLNK /D, otherwise it could run the regular RD command.


    Also Rex, I noticed that MKLINK /? does not show the "/Q" switch but the help file does.
     
  3. Jim Cook

    Joined:
    May 20, 2008
    Messages:
    604
    Likes Received:
    0
    On Tue, Mar 24, 2009 at 4:12 AM, kb1001 <> wrote:


    TCC 10.00.61 Windows XP [Version 5.1.2600]
    TCC Build 61 Windows XP Build 2600 Service Pack 3

    I'm using XP instead of Vista, but my testing does not show what you say.

    The RD command in CMD and TCC both just remove the junction.

    The RD /S command in CMD and TCC both delete the files.


    --
    Jim Cook
    2009 Saturdays: 4/4, 6/6, 8/8, 10/10, 12/12 and 5/9, 9/5, 7/11, 11/7.
    Next year they're Sunday.
     
  4. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,520
    Likes Received:
    4
    Rod Savard wrote:
    | You might be able to set up an RD alias that checks to see if the
    | directory is a junction (perhaps using the @JUNCTION function?). If
    | so it would call MKLNK /D, otherwise it could run the regular RD
    | command.

    Use %@wattrib[dir,L] as your test, e.g., UNTESTED:

    alias RDS=`iff %@wattrib[%1,L] eq 1 then %+ mklnk /d %1 %+ else *rd/s %1 %+
    endiff`

    --
    HTH, Steve
     
  5. kb1001

    Joined:
    Mar 23, 2009
    Messages:
    7
    Likes Received:
    0
    I have just been doing

    alias rd=cmd /c rd

    which works fine. But, I'm worried about someone else who might be running TCC without my alias.

    Kb
     
  6. kb1001

    Joined:
    Mar 23, 2009
    Messages:
    7
    Likes Received:
    0
    Jim,

    Symlinks are new in Vista, and the RD command works differently on Vista than XP. If you try it on Vista you'll see what I mean. I guess someone at Microsoft must have reworked it to avoid the "problem" (at least as far as my usage is concerned.)

    Kb
     
  7. kb1001

    Joined:
    Mar 23, 2009
    Messages:
    7
    Likes Received:
    0
    Steve,

    BTW, the reason I can't use the alias you suggest is that the RD command is recursive. If I do an rd/s on a root that contains a nested linked directory, I don't want it to delete the files.

    Kb
     
  8. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,859
    Likes Received:
    83
    kb1001 wrote:

    Well, yes, you could leave off the /S.

    (I'm puzzled why you would *want* to do an RD /S of a symlink or junction.)

    Rex Conn
    JP Software
     
  9. kb1001

    Joined:
    Mar 23, 2009
    Messages:
    7
    Likes Received:
    0
    In my case, what I want to do is create a (real) directory that contains symlinks to a series of other directories that are scattered about on a disk (or disks), to provide a logical "view" of files different from the physical organization [actually it's more complicated than that because the "view" can be deeply nested with real directories, real files, symlink'd files and symlink'd directories at any level].

    So to clean the view, I must do an "rd/s" and I definitely don't want to delete any files from the symlink'd directories.

    HTH,
    Kb
     
  10. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,520
    Likes Received:
    4
    kb1001 wrote:
    | In my case, what I want to do is create a (real) directory that
    | contains symlinks to a series of other directories that are scattered
    | about on a disk (or disks), to provide a logical "view" of files
    | different from the physical organization [actually it's more
    | complicated than that because the "view" can be deeply nested with
    | real directories, real files, symlink'd files and symlink'd
    | directories at any level].
    |
    | So to clean the view, I must do an "rd/s" and I definitely don't want
    | to delete any files from the symlink'd directories.

    I think you could use DEL /S /NJ /X - but I haven't tested it.
    --
    HTH, Steve
     

Share This Page