Skip to content

Instantly share code, notes, and snippets.

@abdes-zakari
Created December 15, 2021 11:47
Show Gist options
  • Save abdes-zakari/b200c85c2aa43ca921a25e47629f5422 to your computer and use it in GitHub Desktop.
Save abdes-zakari/b200c85c2aa43ca921a25e47629f5422 to your computer and use it in GitHub Desktop.
Windows: get symbolic link target
@echo off
rem Windows: get symbolic link target
rem cmd: get_sym_target.bat <dir> <folder|file>
rem for /f "tokens=2 delims=[]" %%H in ('dir /al %1 ^| findstr /i /c:"%2"') do (
rem echo %%H
rem )
rem cmd: get_sym_target.bat <folder|file> // current directory
for /f "tokens=2 delims=[]" %%H in ('dir /al . ^| findstr /i /c:"%1"') do (
echo %%H
)
@abdes-zakari
Copy link
Author

PowerShell (PSv5+) solutions:

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

Get-ChildItem | ? Target | Select-Object FullName, Target

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment