0

此批处理适用于 Microsoft Windows,其功能是从选定的“路径列表” “从文本文件中读取”递归生成“完整路径” , 然后递归输出到 SET 变量,最后输出到准备部署的批处理文件用于创建符号链接

注意:星号符号*用于您自己的用户名。

问题是:它只输出文本文件中的最后一行。

我需要的解决方案:从文本文件中逐行读取。

批处理“[符号链接 - Alpha].bat”

@ECHO OFF
setlocal EnableDelayedExpansion

for %%i in (.) do set CurName=%%~nxi
for /F "usebackq tokens=*" %%a in ("%cd%\Text.txt") do pushd "A:\%%a"

set FOCUS=for /f "tokens=* delims= " %%i in ('dir /a:d /b') do
set FUNCTION_A=rd /s /q "C:\%cd:~3%\%%i"
set FUNCTION_B=mklink /d "C:\%cd:~3%\%%i" "A:\%cd:~3%\%%i"
set OUTPUT=C:\Batch

type NUL > "%OUTPUT%\{Execution} of %CurName%.bat"
%FOCUS% ECHO %FUNCTION_A% >> "%OUTPUT%\{Execution} of %CurName%.bat"
%FOCUS% ECHO %FUNCTION_B% >> "%OUTPUT%\{Execution} of %CurName%.bat"

输入“文本.txt”

Users\*\AppData\Local
Users\*\AppData\LocalLow
Users\*\AppData\Roaming

输出“Batch.bat 的{Execution}”

rd /s /q "C:\Users\*\AppData\Roaming\Command and Conquer 3 Kanes Wrath" 
rd /s /q "C:\Users\*\AppData\Roaming\Command and Conquer 3 Tiberium Wars" 
rd /s /q "C:\Users\*\AppData\Roaming\Command and Conquer 4" 
mklink /d "C:\Users\*\AppData\Roaming\Command and Conquer 3 Kanes Wrath" "A:\Users\*\AppData\Roaming\Command and Conquer 3 Kanes Wrath" 
mklink /d "C:\Users\*\AppData\Roaming\Command and Conquer 3 Tiberium Wars" "A:\Users\*\AppData\Roaming\Command and Conquer 3 Tiberium Wars" 
mklink /d "C:\Users\*\AppData\Roaming\Command and Conquer 4" "A:\Users\*\AppData\Roaming\Command and Conquer 4"
4

0 回答 0