我正在尝试从%%~ni
中删除空格和逗号。通过将其放入新变量!url!
中,我设法做到了。它回声很好,但是没有人知道为什么我不能在这里使用它:set "line=!line:REPLACE=!url!!"
吗?
@echo off
setlocal enableextensions enabledelayedexpansion
for /R %%i in (*.csv) do (
ren "%%~i" temp.tmp
(for /F "usebackq tokens=*" %%f in ("%%~dpitemp.tmp") do (
set "line=%%f"
echo %%~ni
set url=%%~ni
set url=!url: =-!
set url=!url:,=!
echo !url!
set "line=!line:REPLACE=!url!!"
echo(!line!
)) > "%%~i"
del "%%~dpitemp.tmp"
)
答案 0 :(得分:2)
回答其他有此问题的人
@echo off
setlocal enableextensions enabledelayedexpansion
for /R %%i in (*.csv) do (
ren "%%~i" temp.tmp
(for /F "usebackq tokens=*" %%f in ("%%~dpitemp.tmp") do (
set "line=%%f"
set url=%%~ni
set "url=!url: =-!"
set "url=!url:,=!"
set "url=!url:(=!"
set "url=!url:)=!"
for /F "delims=" %%e in ("!url!") do set "line=!line:REPLACE=%%e!"
echo(!line!
)) > "%%~i"
del "%%~dpitemp.tmp"
)