我想知道如何使用批处理文件创建日记?
我希望能够保存我的日记帐分录并创建日期。如果可能的话,我想使用.log文件保存它。我必须为下面的期刊编写代码。
:JOU
ECHO ====Journal====
echo.
ECHO Please add an entry, Joshua.
@pause >nul
echo.
ECHO ====Entries====
echo.
set /p datej1="Date: "
set /p entriesj1="Entries: "
cls
ECHO 1. Date: %datej1% Entries: %entriesj1%
echo.
set /p datej2="Date: "
set /p entriesj2="Entries: "
echo.
ECHO 2. Date: %datej2% Entries: %entriesj2%
echo.
set /p datej3="Date: "
set /p entriesj3="Entries: "
echo.
ECHO 3. Date: %datej3% Entries: %entriesj3%
echo.
set /p datej4="Date: "
set /p entriesj4="Entries: "
echo.
ECHO 4. Date: %datej4% Entries: %entriesj4%
echo.
set /p datej5="Date: "
set /p entriesj5="Entries: "
echo.
ECHO 5. Date: %datej5% Entries: %entriesj5%
echo.
set /p datej6="Date: "
set /p entriesj6="Entries: "
echo.
ECHO 6. Date: %datej6% Entries: %entriesj6%
echo.
set /p datej7="Date: "
set /p entriesj7="Entries: "
echo.
ECHO 7. Date: %datej7% Entries: %entriesj7%
echo.
set /p datej8="Date: "
set /p entriesj8="Entries: "
echo.
ECHO 8. Date: %datej8% Entries: %entriesj8%
echo.
set /p datej9="Date: "
set /p entriesj9="Entries: "
echo.
ECHO 9. Date: %datej9% Entries: %entriesj9%
echo.
set /p datej10="Date: "
set /p entriesj10="Entries: "
echo.
ECHO 10. Date: %datej10% Entries: %entriesj10%
echo.
ECHO Press any key to exit Journal.
@pause >nul
cls
答案 0 :(得分:1)
试试这个,它会将你输入cmd的所有内容保存到桌面上作为Logs.log(你不能用这个删除行,所以请确保你在输入时不要犯任何错误!)
@echo off
goto :EditText
:EditText
set /p TextInput=
echo %TextInput% >> %systemdrive%/Users/%username%/Desktop/Logs.log
goto :EditText
如果您希望将日期和时间添加到日记帐分录,请改用此代码:
@echo off
set A=%systemdrive%/Users/%username%/Desktop/Logs.log
goto :EditText
:EditText
set /p TextInput=
echo. >> %A%
echo %time% on %date%: >> %A%
echo %TextInput% >> %A%
goto :EditText
答案 1 :(得分:0)
这可能是下面的有用替代方案。
:Code
@ECHO OFF
START notepad "%userprofile%\Desktop\Diary.txt"
END
在桌面上创建文件Diary.txt
并在其中编写.LOG。关闭它然后在.bat文件中运行:Code
。
它会将日期和时间以及您键入的内容保存到Diary.txt
答案 2 :(得分:0)
这是最简单的答案:
现在你可以用它作为你的日记。 当您打开它时,它会自动写入日期并每次保存您的文本。