windows symbolic link target windows symbolic link target windows windows

windows symbolic link target


As Harry Johnston said dir command shows the target of symbolic links

2014/07/31  11:22    <DIR>          libs2014/08/01  13:53             4,997 mobile.iml2014/07/31  11:22               689 proguard-rules.pro2014/09/28  10:54    <JUNCTION>     res [\??\C:\Users\_____\mobile\src\main\res]


To complement Paul Verest's helpful answer:

  • While cmd's dir indeed shows the link type and target path, extracting that information is nontrivial - see below for a PowerShell alternative.

  • In order to discover all links in the current directory, use dir /aL.

PowerShell (PSv5+) solutions:

List all links and their targets in the current directory as full paths:

PS> Get-ChildItem | ? Target | Select-Object FullName, TargetFullName                      Target--------                      ------C:\root\public\mytextfile.txt {C:\root\Public\myothertextfile.txt}

Determine a given link's target:

PS> (Get-Item C:\root\Public\mytextfile.txt).TargetC:\root\Public\myothertextfile.txt


Write a batch file( get_target.bat) to get the target of the symbolic link:

@echo offfor /f "tokens=2 delims=[]" %%H in  ('dir /al %1 ^| findstr /i /c:"%2"') do (    echo %%H)

For example, to get the target of C:\root\Public\mytextfile.txt:

get_target.bat C:\root\Public\ mytextfile.txt