@echo off
echo processing please wait...
setlocal enabledelayedexpansion
set txtfile=%~dp0mysql\my.ini.bak
set newfile=%~dp0mysql\my.ini
if exist "%newfile%" del /f /q "%newfile%"
for /f "tokens=*" %%a in (%txtfile%) do (
set newline=%%a
echo !newline! >> %newfile%
)
Now my.ini.bak file is in D:\Program Files\my.ini.bak
Error : The system cannot find the file Files\mysql\my.ini.bak.
How to make this code work, so it copy each line from my.ini.bak to my.ini
I don’t think you need to quote the paths, you can just use the short names in the expanded path. So use %~dps instead of %~dp
By the way, the error I get with your original code is slightly different from your error, not sure why.