How can aliases of a folder be found using cmd?

3

Is it possible to find the aliases that correspond to a certain folder (and perhaps its sub-directories, too) using Windows cmd? I've tried searching, but it gives me results related to creating aliases for commands, like in Bash. I'm connecting to Windows Server 2008 R2 from a Windows 7 client.

FlyingMolga

Posted 2012-07-26T15:33:25.767

Reputation: 271

2

By alias, do you mean hard links and/or symlinks?

– Dennis – 2012-07-26T15:49:08.640

I'm mainly looking for symlinks, but both, if that's possible... – FlyingMolga – 2012-07-26T18:57:35.070

Answers

2

Symbolic links and directory junctions

With dir, you can list all symlinks and junctions in a specific folder and its subfolders.

If you pipe the result to find, you can filter out any links that do not interest you.

Examples:

  • To find all symlinks and junctions on C: that point to C:\Users, use

    dir C:\ /al /s | find /i "[C:\Users]"
    
  • To find all symlinks and junctions on C: that point to C:\Users or one of its subdirectories, use

    dir C:\ /al /s | find /i "[C:\Users\"
    

Unfortunately, this won't tell where the files are located. grep for Windows gives better results:

Examples:

dir C:\ /al /s | grep -Pi "Directory of|\[C:\\Users\]"
dir C:\ /al /s | grep -i "Directory of\|\[C:\\Users\\\\"

Note that you have to escape the brackets, double the backslashes and quadruple a trailing backslash.

Hard links

Because hard links are directly associated to a file by the file system, it's much easier/faster to find them.

To find all hard links to file, use

fsutil hardlink list file

Dennis

Posted 2012-07-26T15:33:25.767

Reputation: 42 934