我正在尝试创建一个执行此操作的批处理文件:
Batch File
/ ^
/ |
Batch file that echoes File data
|
File data
但是,使用下面的代码,我无法将百分号 (%) 回显到其他文件中。 假设我有输入字符串:
echo %var%
在输出文件中,它说:
echo
还有办法回显百分号吗?我可以
echo %%var%%
但我需要自动执行它。
我的代码:
@echo off
:Filename
del /f /q temp 1>nul 2>nul
echo Filename:
set /p file="> "
if not exist %file% echo The filename specified does not exist.
echo %file% | findstr /v .bat | findstr /v .cmd> temp
for /f %%i in (temp) do set test=%%i
if not %test%.==. echo The file specified is not a batch or cmd file. & goto Filename
:Confirmed
del /f /q temp
echo Target file name:
set /p target="> "
cls
set fileo=%file:.=o.%
echo @echo off> %fileo%
echo setlocal enabledelayedexpansion>> %fileo%
for /f "usebackq delims=" %%i in (%file%) do (
echo set line="%%i">> %fileo%
echo set line=%%line:~1,-1%%>> %fileo%
echo echo %%line%%^>^> %target%>> %fileo%
)
echo Finished code:
echo ====================
type %fileo%
echo.
echo Press any key to exit.
pause>nul
谢谢!