@echo off
SET str1=type %1
SET str2=type %2
echo File1: %str1%
echo
echo File2: %str2%
你可能知道我想要什么,但是命令行解释器没有。如何正确地做到这一点?如何将文件内容分配给变量?
PS。我的意思是整个内容,不仅是第一行!
@echo off
SET str1=type %1
SET str2=type %2
echo File1: %str1%
echo
echo File2: %str2%
你可能知道我想要什么,但是命令行解释器没有。如何正确地做到这一点?如何将文件内容分配给变量?
PS。我的意思是整个内容,不仅是第一行!
对于内容(全系):
@echo off &setlocal enabledelayedexpansion
set "files=1"
if "%~1"=="" set "files="
if "%~2"=="" set "files="
if not defined files echo Missing filename(s^).&goto:eof
:: read the first file
set /a cnt1=0
for /f "usebackqdelims=" %%i in ("%~1") do set /a cnt1+=1 &set "str1!cnt1!=%%i"
:: read the second file
set /a cnt2=0
for /f "usebackqdelims=" %%i in ("%~2") do set /a cnt2+=1 &set "str2!cnt2!=%%i"
:: write the first file
echo File1:
for /l %%i in (1,1,%cnt1%) do echo !str1%%i!
:: write the second file
echo File2:
for /l %%i in (1,1,%cnt2%) do echo !str2%%i!
endlocal
我做了一个关于“内容”的编辑。 – Endoro 2013-03-21 18:42:45
问题已更新 – 0x6B6F77616C74 2013-03-21 19:09:34
'%1'和'%〜1'有什么区别? – 0x6B6F77616C74 2013-03-24 02:20:46
你的意思是从文件中读取一个变量? – Magoo 2013-03-21 17:53:14
您可以将内容逐行放入一组变量中。 – Endoro 2013-03-21 19:28:44
答复更新... – Endoro 2013-03-21 21:53:28