Batch basis (xiv) insert content before the file

file_exist.bat document reads as follows:
Note: del /f /qcommand, / f represents the force the removal of read-only files. / q represents the quiet mode, delete the global wildcard character that does not require confirmation.

@echo off
if "%1"=="" (
echo 命令用法:
echo %0 fileName
echo fileName 表示要插入内容的文件
echo.
echo 未指定要插入内容的文件,无法执行插入操作!
echo.
goto end
)

if not exist %1 (
echo 指定要插入的%1文件不存在,请仔细检查!
goto end
)

echo 正在进行插入操作......
echo.
echo %date% >> content.txt
echo %time% >> content.txt
copy content.txt + %1 temp.txt > nul
del /f /q %1 > nul
del /f /q content.txt > nul
ren temp.txt %1
echo 成功在%1文件前插入当前日期及时间!
:end

Here Insert Picture Description

Published 228 original articles · won praise 44 · Views 100,000 +

Guess you like

Origin blog.csdn.net/qq_40945965/article/details/86757434