这是我目前的.bat
:
set /p lastname=Please enter last name:
set /p firstname=Please enter first name:
set /p sex=Please enter sex:
set /p age=Please enter age:
set /p weight=Please enter weight (kg):
set /p location=Please enter location:
set /p admitdate=Please enter admit date:
mkdir %lastname%%firstname:~0,1%
cd %lastname%%firstname:~0,1%
echo|set /p=%lastname%>lastname.txt
echo|set /p=%firstname%>firstname.txt
echo|set /p=%age%>age.txt
echo|set /p=%sex%>sex.txt
echo|set /p=%weight%>weight.txt
echo|set /p=%location%>location.txt
echo|set /p=%admitdate%>admitdate.txt
我正在尝试将每个变量写入自己的.txt
。当我回到.txt
时,我很难摆脱尾随的空格。例如,如果lastname
是Smith,则lastname.txt
显示为Smith_
,其中_
表示空格。
到目前为止我的尝试包括:
%firstname% > firstname.txt
至%firstname%>firstname.txt
。>firstname.txt echo|set /p=%firstname%
。这只会使每个.txt
说Echo is ON
。这些方法都没有奏效。为了您的信息,我也试图摆脱追踪\n
的{{1}}。到目前为止,我已经使用echo
完成了这项工作。
答案 0 :(得分:3)
这个结构对我有用:
@set firstname=John
@<nul >firstname.txt set /p=%firstname%