中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-11 11:40
47,811 topics / 349,897 posts / today 0 new / 48,256 members
DOS批处理 & 脚本技术(批处理室) » [fixed] Question about replacing specified content in a file
Printable Version  764 / 9
Floor1 zuoyuanchun Posted 2009-02-26 01:43
新手上路 Posts 8 Credits 11
Source file contents:
Q(0)="If you don't equip a magic treasure, you won't be able to use it?"
A(0)="Combat skill"
Q(1)="At which NPC can you use a dim inner core to exchange for the mount summoning talisman you want?"
A(1)="Shitang County Demon Sealer"
Q(2)="Which of the following statements is correct?"
A(2)="If a red-name attacks a white-name, criminal points will increase"
Q(3)="What professions' magic treasures can be obtained by raising government prestige?"
A(3)="Warrior, Ranger"
Q(4)="Which shortcut key opens the etiquette action interface? "
A(4)="Key P"
……
……
Replace with:
@@If you don't equip a magic treasure, you won't be able to use it?
Combat skill
@@At which NPC can you use a dim inner core to exchange for the mount summoning talisman you want?
Shitang County Demon Sealer
@@Which of the following statements is correct?
If a red-name attacks a white-name, criminal points will increase
@@What professions' magic treasures can be obtained by raising government prestige?
Warrior
Ranger
@@Which shortcut key opens the etiquette action interface?
Key P


The problem seems quite complicated, and besides, I don't really understand batch files. Thanks a lot for everyone's help.
Additional note: the filename is 1.txt
I tested both people's versions and they don't work
Also, there are numbers in the questions here, and those numbers can't be deleted.

[ Last edited by zuoyuanchun on 2009-2-27 at 04:30 ]
Floor2 netbenton Posted 2009-02-26 02:34
银牌会员 Posts 752 Credits 1,916 From 广西
@echo off&setlocal enabledelayedexpansion
for /f "tokens=1,* delims==" %%a in (source file) do set str=%%a&call :sub!str:~0,1! %%~b
goto :eof
:subQ
echo @@%*
goto :eof

:subA
echo.%1
shift
if "%1"=="" goto :eof
goto :subA

[ Last edited by netbenton on 2009-2-26 at 12:12 ]
Floor3 lxmxn Posted 2009-02-26 05:25
版主 Posts 4,938 Credits 11,386
Floor4 zuoyuanchun Posted 2009-02-26 08:49
新手上路 Posts 8 Credits 11
http://upload.cn-dos.net/img/1331.txt
I've already uploaded it, so everyone can just help write a batch file to process it directly, thanks
Floor5 netbenton Posted 2009-02-26 14:11
银牌会员 Posts 752 Credits 1,916 From 广西
Floor6 moniuming Posted 2009-02-26 22:51
银牌会员 Posts 574 Credits 1,335 From 广西
Floor7 tireless Posted 2009-02-27 01:22
银牌会员 Posts 1,122 Credits 2,025
Floor8 zuoyuanchun Posted 2009-02-27 04:30
新手上路 Posts 8 Credits 11
Originally posted by moniuming at 2009-2-26 22:51:
Floor9 terse Posted 2009-02-27 04:32
银牌会员 Posts 946 Credits 2,404
Floor10 netbenton Posted 2009-02-27 09:06
银牌会员 Posts 752 Credits 1,916 From 广西
...
@@At which NPC can you use a dim inner core to exchange for the mount summoning talisman you want?
Shitang County Demon Sealer
@@Which of the following statements is correct?
If a red-name attacks a white-name, criminal points will increase
@@What professions' magic treasures can be obtained by raising government prestige?
Warrior
Ranger

@@Which shortcut key opens the etiquette action interface?
Key P
...



Question for the OP: should the red part here be split onto separate lines?
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023