本文介绍了如何处理文件名的空间批次循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
@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%
)
现在my.ini.bak文件在D:\\ Program Files文件\\ my.ini.bak结果
错误:系统无法找到该文件的文件\\ MySQL的\\ my.ini.bak
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.
如何让这个code的工作,所以它my.ini.bak复制每一行MY.INI
How to make this code work, so it copy each line from my.ini.bak to my.ini
推荐答案
我不认为你需要引用的路径,你可以在扩展路径中使用的短名称。因此,使用%〜DPS代替%〜DP
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
@echo off
echo processing please wait...
setlocal enabledelayedexpansion
set txtfile=%~dps0mysql\my.ini.bak
set newfile=%~dps0mysql\my.ini
if exist "%newfile%" del /f /q "%newfile%"
for /f "tokens=*" %%a in (%txtfile%) do (
set newline=%%a
echo !newline! >> %newfile%
)
顺便说一句,我跟你原来的code得到的错误是从你的错误略有不同,不知道为什么。
By the way, the error I get with your original code is slightly different from your error, not sure why.
The system cannot find the file C:\Program.
这篇关于如何处理文件名的空间批次循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!