From 08f3b1a1fc080b733c1bc052c214fc68d06baeb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=BD=E7=A7=8B=E6=9E=AB=E5=8F=B6?= <59348827+lqfy-jhc@users.noreply.github.com> Date: Sat, 30 Sep 2023 01:49:23 +0800 Subject: [PATCH] Update fileLink.bat MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 已修正,绝对路径某文件夹中带有空格,导致生成失败 提升,链接文件都将生成在脚本所在目录(c盘将能直接生成在脚本所在地,非c盘需要将%userprofile%\Desktop\LinkBox\目录下生成的脚本文件拖到需要的目标目录,右键管理员运行后将在此脚本目录产生链接文件) 继续优化调整 --- "\350\265\24211/fileLink.bat" | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git "a/\350\265\24211/fileLink.bat" "b/\350\265\24211/fileLink.bat" index e4f3791..102c34e 100644 --- "a/\350\265\24211/fileLink.bat" +++ "b/\350\265\24211/fileLink.bat" @@ -4,13 +4,13 @@ set flieAttribute="--a--------" set directoryAttribute="d----------" ::rem 设定存放脚本及映射的目录 set mappingPath=%userprofile%\Desktop\LinkBox\ -set CLinkBoxPath=%mappingPath%%~nx1 +set CLinkBoxPath=%mappingPath% ::rem 脚本所在地即为链接生成地 -set tagHome="%~dp0" +set tagHome=%~dp0 set OLinkBoxPath=%~d1\LinkBox\ set Obat=%CLinkBoxPath%跨盘符需管理员权限%~n1.bat ::rem 创建脚本及映射目录 -if exist %CLinkBoxPath% ( echo "%CLinkBoxPath%" ) else ( mkdir %CLinkBoxPath% ) +if exist %CLinkBoxPath% ( echo "%CLinkBoxPath%%~nx1" ) else ( mkdir %CLinkBoxPath% ) ::rem 核验变量 echo attribute:%attribute% ::echo flieAttribute:%flieAttribute% @@ -21,13 +21,13 @@ if "C:"=="%~d1" ( goto intoC ) else ( goto intoO ) :intoC if %flieAttribute%==%attribute% ( - MKLINK /H "%tagHome%" "%~1" + MKLINK /H "%tagHome%%~nx1" "%~1" echo "--a--------H" ) else if %directoryAttribute%==%attribute% ( - MKLINK /J "%tagHome%" "%~1" + MKLINK /J "%tagHome%%~nx1" "%~1" echo "d----------J" ) else ( - MKLINK /D "%tagHome%" "%~1" + MKLINK /D "%tagHome%%~nx1" "%~1" echo "-----------D" ) goto end @@ -45,17 +45,17 @@ if "C:"=="%~d1" ( goto intoC ) else ( goto intoO ) ) > %Obat% if %flieAttribute%==%attribute% ( ( - echo MKLINK "%tagHome%" "%~1" + echo MKLINK "%tagHome%%~nx1" "%~1" echo echo --a--------H ) >> %Obat% ) else if %directoryAttribute%==%attribute% ( ( - echo MKLINK /D "%tagHome%" "%~1" + echo MKLINK /D "%tagHome%%~nx1" "%~1" echo echo d----------J ) >> %Obat% ) else ( ( - echo MKLINK /D "%tagHome%" "%~1" + echo MKLINK /D "%tagHome%%~nx1" "%~1" echo echo -----------D ) >> %Obat% )