1. You are viewing our forum as a guest. For full access please Register. WindowsBBS.com is completely free, paid for by advertisers and donations.

Resolved Robocopy not copying target of shortcuts

Discussion in 'Other PC Software' started by MarkBL, 2012/02/08.

  1. 2012/02/08
    MarkBL

    MarkBL Inactive Thread Starter

    Joined:
    2012/02/08
    Messages:
    7
    Likes Received:
    0
    Trying to use robocopy to setup backups, not able to get it to copy the target of a file shortcut, it just copies the shortcut itself. Don't see any flags to turn that feature on, it says it works that way by default. Here's the exact command I've whittled it down to, dir1 contains a single shortcut that points to a file on another drive, dir2 is empty:

    robocopy e:\dir1 e:\dir2
     
  2. 2012/02/08
    SpywareDr

    SpywareDr SuperGeek WindowsBBS Team Member

    Joined:
    2005/12/31
    Messages:
    3,752
    Likes Received:
    338

  3. to hide this advert.

  4. 2012/02/08
    MarkBL

    MarkBL Inactive Thread Starter

    Joined:
    2012/02/08
    Messages:
    7
    Likes Received:
    0
    This problem started because I tried to backup the contents of my desktop folder to a backup disk. My desktop contains a shortcut to MyDocuments (both desktop and MyDocuments live under a folder called Mark). I expected the backup to contain the actual contents of MyDocuments, instead it only contained the link. You're correct, I could change my backup script to backup the directory Mark and exclude all the subdirectories I don't want to backup. But that's not the easiest solution, particularly since I'll have to go through the entire directory tree and see if this problem crops up anywhere else. It's also not the way robocopy is supposed to work (I think).
     
  5. 2012/02/10
    Arie

    Arie Administrator Administrator Staff

    Joined:
    2001/12/27
    Messages:
    15,174
    Likes Received:
    412
    I would expect the program is working exactly as it should.

    A shortcut is a file containing a target URI or GUID to an object, or the name of a target program file that the shortcut represents.

    If it was an (NTFS) junction point it would behave in the way you expect a shortcut to work. A junction point provides the ability to create a symbolic link to a directory which then functions as an alias of that directory.
     
    Arie,
    #4
  6. 2012/02/10
    SpywareDr

    SpywareDr SuperGeek WindowsBBS Team Member

    Joined:
    2005/12/31
    Messages:
    3,752
    Likes Received:
    338
  7. 2012/02/10
    Arie

    Arie Administrator Administrator Staff

    Joined:
    2001/12/27
    Messages:
    15,174
    Likes Received:
    412
    When you think about it it doesn't make sense to follow a shortcut link, as 9 out of 10 times it will be a link to an other file (document or program) that would be backed up in its own location.
     
    Arie,
    #6
  8. 2012/02/10
    MarkBL

    MarkBL Inactive Thread Starter

    Joined:
    2012/02/08
    Messages:
    7
    Likes Received:
    0
    As you say, 9 out of 10 times it might not be desireable to follow a shortcut, but every 10th time it makes sense.

    Perhaps my expectation is colored by having used Unix, where tools like cpio have switches to choose whether or not to resolve a symbolic link or just copy the link itself. I did a fair bit of researching robocopy and there are many tech articles online that indicate it is capable of copying the target of shortcuts. Once I looked in the actual manual it's clear they don't mention the word shortcut, which seems strange, particularly since they discuss junction points and links. I was not familiar with junction points in windows, which seems to be a construct only used to link directories.

    Anyway, this is not a showstopper for what I'm trying to do, just something I need to be aware of.
     
  9. 2012/02/10
    Admin.

    Admin. Administrator Administrator Staff

    Joined:
    2001/12/30
    Messages:
    6,687
    Likes Received:
    107
    robocopy is capable of doing exactly that. A shortcut in Windows is not a symbolic link.

    The /sl option copies the symbolic link instead of the target.

    More info: TechNet Library
     
  10. 2012/02/10
    MarkBL

    MarkBL Inactive Thread Starter

    Joined:
    2012/02/08
    Messages:
    7
    Likes Received:
    0
    Thanks for help, I understand.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.