What is the file extension for a symbolic link?


  1. Posts : 661
    Windows 7 Home Premium SP1 64-bit
       #1

    What is the file extension for a symbolic link?


    I want to write a batch script which backs up folders (no problem) but which will ignore symbolic links (shortcuts) in those folders (problem! Simply because I don't know what the file extension is to write the exclude into the script: it isn't '.lnk'). I didn't find the answer after Googling either.

    Anyone know how I can do this (I use XXCopy BTW)
      My Computer


  2. Posts : 31,242
    Windows 11 Pro x64 [Latest Release and Release Preview]
       #2

    Not directly but if you take a look on Microsoft's Sysinternals site there are a few utilities, (including some CMD capable), that may allow you to do what you wish

    There is a full set of corresponding documentation that is in good depth
      My Computers


  3. Posts : 661
    Windows 7 Home Premium SP1 64-bit
    Thread Starter
       #3

    Thanks. I already use a number of little programmes from Sysinternals, but I am not sure which one you were thinking of with regard to including symlinks in batch scripts?

    Perhaps I just use the address of the folders/files to which the symlinks connect?
      My Computer


  4. Posts : 54
    windows 7 64bit
       #4

    Have you tried using powershell to view it?
    Probably like unix ls?

    Also, are you sure xcopy is backing up symbolic links?
      My Computer


  5. Posts : 661
    Windows 7 Home Premium SP1 64-bit
    Thread Starter
       #5

    Have you tried using powershell to view it?
    Sorry, I think we are at crossed purposes. To view what? This is really about script writing. I want to exclude any symbolic links in a folder when writing a batch script, but I don't know how to specify symlinks.

    For instance:

    /X"C:\New Folder\*.lnk"

    would exclude any normal shortcuts. But it won't exclude sympbolic links.
      My Computer


  6. Posts : 2,465
    Windows 7 Ultimate x64
       #6

    There is no such thing as an "extension" for symbolic links (or hard links, or junctions, for that matter). They're NOT just plain files, they're special file system objects that behave differently than anything else. They only exist on NTFS, where the file system can hold their special properties, but not on FAT32 for example. As such, you can't rely on an "extension" to identify them.

    In contraposition, shortcuts are just normal files with a particular format, not different to .txt, .mp3 or .xls. Windows Explorer understands its format and uses it to find another file, that's all about them. It's a convention that they use a .lnk extension. Windows Explorer purposely hide this away, even when told not to, but any decent file manager (including a plain old dir command) can show it.

    Back to the topic, if you want a way to exclude them, you need to identify them beforehand. The only feature in XCOPY that mentions them is the /B switch that copies the link itself instead of duplicating the target (it makes no mention of junctions and hard links, however). I looked that at this reference.

    I found this post at SuperUser talking about a similar issue:
    windows 7 - How to view all the Symbolic links,Junction points,Hard links in a Folder using dir? - Super User

    This shows different ways to view the symbolic links. Focus on those that suggest command line tools, as their output can be used for further processing, including feeding XCOPY an adequate exclusion list. I personaly like the PowerShell alternative, showing all types of special file system objects. That should serve you well to script the backup.
      My Computer


  7. Posts : 661
    Windows 7 Home Premium SP1 64-bit
    Thread Starter
       #7

    Thanks for the reply. I use XXCopy or (Robocopy sometimes) and for now I can exclude the symlink targets from being backed up (over 3TBs of data in all) as they all have a part of the file name in common - so with some wildcard characters that works.

    I'll have a look at the links you posted of course - thanks again for the information.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 05:00.
Find Us