Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In Windows 7, how can I check if a file is a symbolic link or not, if a folder is a junction or not, and how can I check where they are pointing at (in case they are symlink/junction). Both in Explorer and in Command line.

It's very important to have a way to do it from command line, in order to know how to duplicate symbolic links on another computer when you want to make an exact replica of a folder tree.

If I right click on a file and check "Properties", I can't find any indication that it's a symbolic link.

share|improve this question

migrated from stackoverflow.com Dec 27 '12 at 5:48

This question came from our site for professional and enthusiast programmers.

up vote 7 down vote accepted

I believe you are looking for dir

2012-12-26  09:30 PM    <DIR>          .
2012-12-26  09:30 PM    <DIR>          ..
2012-12-26  09:30 PM                 0 a.txt
2012-12-26  09:30 PM    <SYMLINK>      link.txt [a.txt]
share|improve this answer
    
This doesn't work in windows 7 (Microsoft Windows [Version 6.1.7601]) – gonzalezea Mar 24 at 14:00
    
@gonzalezea yeah, it does. It worked with Windows 7 back in 2012 when I posted this, and it works now too – Steven Penny Mar 24 at 15:22

Copied from StackOverFlow, I just used this line, and it works

fsutil reparsepoint query "folder name" | find "Symbolic Link" >nul && echo symbolic link found || echo No symbolic link

Explanation:

From MSDN about FSUtil : Performs tasks that are related to file allocation table (FAT) and NTFS file systems, such as managing reparse points, managing sparse files, or dismounting a volume. If it is used without parameters, fsutil displays a list of supported subcommands.

For our use, we just care that it outputs a line that has "Symbolic Link" in it, if it's symbolic, which we then find, and if find succeeds, we output one thing, if it doesn't, we output something else.

Notes:

  • The quotes around the folder name are required if the path has spaces in it.
  • It gives the same output whether the folder doesn't exist, or isn't a symlink, use with caution.
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.