比较来自世界各地的卖家的域名和 IT 服务价格

如何自动发现破坏的符号链接 Windows?

不确定这是一个糟糕的风格,但我在这里问这个问题,因为我在其他地方找不到答案,然后我自己开发了一个决定。 我有兴趣看到其他人的解决方案,但在几天之后,我会发布自己的。

在我的特殊情况下,我工作 Windows 7, 但我对他人的答案感兴趣 / 更多旧版本 Windows. 我明白一个答案 - “安装版本 Unix, 找到,然后
https://serverfault.com/questi ... cally
", 但我想要更多" 本国的 "解决方案。

编辑 2012-07-17:

澄清:在“自动”下,我理想地意味着我可以作为脚本的一部分运行,而不是一个工具,而不是按下按钮执行所有工作的工具,因为我想在没有监督的情况下执行此操作。
已邀请:

莫问

赞同来自:

很晚,但这是我对我的问题的答案。 事实上,它与通常的方法相同 Unix: 找到所有链接,然后进程禁用; 这不是简明扼要。 下面的场景删除了卸载有关它们的一些信息后的符号链接。

@echo off

rem Grab the list of directories to scan, before we "pushd to dir containing this script",
rem so that we can have the default be "dir from which we ran this script".
setlocal
if x%CD%==x (echo Command Extensions must be enabled. && goto :eof)
set ORIGINAL_DIR=%CD%

pushd %~dp0

set DIRS_TO_CHECK=%*
if x%DIRS_TO_CHECK%==x (
set DIRS_TO_CHECK=.
)

rem Find all the files which are both links (/al) and directories (/ad).
rem (We use "delims=" in case any paths have a space; space is a delim by default.)
rem If not, delete it (and assume something else will fix it later :-).
echo Deleting broken symlinks ...
echo.
for %%D in (%ORIGINAL_DIR%\%DIRS_TO_CHECK%) do (
echo Checking %%D
echo.
pushd %%D
if errorlevel 1 (
echo Cannot find "%%D"
echo.
goto :Next_Dir
)
rem Clean up broken directory links.
for /f "usebackq delims=" %%L in (`dir /adl /b`) do (
rem Check the directory link works.
rem Redirecting to nul just to hide "The system cannot find the file specified." message.
pushd "%%L" >nul 2>&1
if errorlevel 1 (
echo Deleting broken directory symlink "%%L".
rem First dump out some info on the link, before we delete it.
rem I'd rather a more human-readable form, but don't know how to get that.
fsutil reparsepoint query "%%L"
rmdir "%%L"
echo.
) else (
popd
)
)
rem Clean up broken file (non-directory) links.
for /f "usebackq delims=" %%L in (`dir /a-dl /b`) do (
rem Check the file link works.
rem Redirecting to nul just to hide "The system cannot find the file specified." message.
copy "%%L" nul >nul 2>&1
if errorlevel 1 (
echo Deleting broken file symlink "%%L".
rem First dump out some info on the link, before we delete it.
rem I'd rather a more human-readable form, but don't know how to get that.
fsutil reparsepoint query "%%L"
rm "%%L"
echo.
) else (
popd
)
)
popd
:Next_Dir
rem Putting a label on the line immediately before a ')' causes a batch file parse error, hence this comment.
)
echo Deleting broken symlinks ... done.

:Finally
popd

帅驴

赞同来自:

以下工具可以帮助您找到并删除符号链接 Windows.

http://www.rekenwonder.com/linkmagic.htm
Diskjunction

三叔

赞同来自:

您还可以尝试一个名为的开源实用程序
https://github.com/raspopov/SageLinks/releases
, 它显示并检查连接 Windows NTFS, 符号链接甚至标签。

喜特乐

赞同来自:

使用 cygwin64 (find, xargs, sh, ls) (上班 win7 在死亡的存在下存在 ntfs)

c:\>   find ./ -type l |  xargs -I % sh -c "ls % > /dev/null 2>&1 || echo %" 

笔记: test -e 无法使用艰难的参考不正常工作 ntfs.

要回复问题请先登录注册