是否有将文本写入多个文件?我正在开展一个项目,我需要在个人桌面上写一个特定的号码,一个用于闪存驱动器,它将根据用户的用户名保存和索引号码。
我想做什么:
echo %random%>>"C:\users\%username%\desktop\num.txt" "D:\Numbers\%username%.txt"
答案 0 :(得分:0)
这有效!
echo %random%| cmd /V:ON /C set /P "line=" ^& echo !line!^>^> "C:\users\%username%\desktop\num.txt" ^& echo !line!^>^> "D:\Numbers\%username%.txt"
答案 1 :(得分:0)
为此实现一个(非常简单的)例程:
REM define "command":
set "log=call :log"
%log% hello world!
%log% I have %random% apples.
goto :eof
:log
REM writes the same line to screen and two files
>con: echo(%*
>>"C:\users\%username%\desktop\num.txt" echo(%*
>>"D:\Numbers\%username%.txt" echo(%*
答案 2 :(得分:-1)
您只需在桌面上阅读该文件,为该数字指定一个变量并将其回显到另一个文件中。
echo%random%>>“C:\ users \%username%\ desktop \ number.txt”
FOR / F“tokens = * delims =”%% x in(C:\ users \%username%\ desktop \ number.txt)DO set number = %% x
echo%number%>> D:\ Numbers \%username%.txt