此結果只能排除有SS23 那行,並找到2-->%%b(要刪除的行數),請問如何再利用 for 迴圈將 %%b 往下省略2行文字
(自刪)
連copilot都呆掉,一模一樣..
可以改用powershell或python嗎?
我自己處理好了 !
你不用回這種沒幫助東西 !
看來你也是不會才把我問題丟去copilot不是嗎 ? 笑死
我文件不只是SS23圖層要處理,這只是其中遇到的一種才拿出來發問 !
我還要把它轉成AUTOCAD的語法輸入坐標畫出GIS地圖
弄成批次檔我放桌面滑鼠點一下就處理好 !
'''
@echo off
setlocal enabledelayedexpansion
set "inputFile=----"
set "outputFile=----"
set /a start=0
set /a endd=0
(for /f "delims=" %%a in (!inputFile!) do (
set "line=%%a"
if "!line:~0,6!" equ "0 SS23" (
for /f "tokens=3" %%b in ("!line!") do (
::echo %%b
rem Do nothing (skip this line)
set /a start=!start!+1
set /a endd=!start!+%%b
)
) else (
set /a start=!start!+1
if !endd! lss !start! echo !line!
)
)) >> !outputFile!
copy ---- ----
del ----
endlocal
'''
'''
@echo off
setlocal enabledelayedexpansion
set "inputFile=----"
set "outputFile=----"
(for /f "delims=" %%a in (!inputFile!) do (
set "line=%%a"
set "modifiedLine=!line: =,!"
if "!modifiedLine:~0,6!" equ "0,0150" (
echo.
echo PL
) else if "!modifiedLine:~0,6!" equ "0,0158" (
echo.
echo PL
) else if "!modifiedLine:~0,6!" equ "0,0130" (
echo.
echo PL
) else if "!modifiedLine:~0,6!" equ "0,0151" (
echo.
echo PL
) else if "!modifiedLine:~0,6!" equ "0,SS22" (
echo.
echo PL
) else if "!modifiedLine:~0,6!" equ "0,0157" (
echo.
echo PL
) else if "!modifiedLine:~0,6!" equ "0,0152" (
echo.
echo PL
) else if "!modifiedLine:~0,9!" equ "2,0130-1," (
set "line=!line: =,!"
set "line=!line:,= ,!"
set "line=!line: ,=,!"
set "remaining_text=!line:~9!"
echo.
echo PL
echo !remaining_text!
) else if "!modifiedLine:~0,7!" equ "2,0141," (
set "line=!line: =,!"
set "line=!line:,= ,!"
set "line=!line: ,=,!"
set "remaining_text=!line:~7!"
echo.
echo PL
echo !remaining_text!
) else if "!modifiedLine:~0,7!" equ "2,0157," (
set "line=!line: =,!"
set "line=!line:,= ,!"
set "line=!line: ,=,!"
set "remaining_text=!line:~7!"
echo.
echo PL
echo !remaining_text!
) else if "!modifiedLine:~0,7!" equ "2,0158," (
set "line=!line: =,!"
set "line=!line:,= ,!"
set "line=!line: ,=,!"
set "remaining_text=!line:~7!"
echo.
echo PL
echo !remaining_text!
) else if "!modifiedLine:~0,4!" equ "1,SS" (
rem Do nothing (skip this line)
) else if "!modifiedLine:~0,4!" equ "2,SS" (
rem Do nothing (skip this line)
) else if "!modifiedLine:~0,6!" equ "1,0199" (
rem Do nothing (skip this line)
) else if "!modifiedLine:~0,6!" equ "1,0159" (
rem Do nothing (skip this line)
) else if "!modifiedLine:~0,6!" equ "2,SS23" (
rem Do nothing (skip this line)
) else (
echo !modifiedLine!
)
)) > !outputFile!
set "inputFile=----"
set "oldText=,0.0"&&set "newText="
powershell -Command "(Get-Content '%inputFile%') -replace '%oldText%', '%newText%' | Set-Content '%inputFile%'"
set "oldText=,7"&&set "newText="
powershell -Command "(Get-Content '%inputFile%') -replace '%oldText%', '%newText%' | Set-Content '%inputFile%'"
endlocal
'''
第一次看到發問者出來噴回答者
我也是第一次看到發問者嗆人的..
畢竟沒有人有義務解決樓主的問題,態度還是要注意一下的
有句話叫 做人留一線,日後好相見