中国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-05 18:36
48,039 topics / 350,124 posts / today 2 new / 48,251 members
DOS批处理 & 脚本技术(批处理室) » Problems with text and letter substitution in files?
Printable Version  6,039 / 29
Floor1 zouzhxi Posted 2006-10-15 10:36
中级用户 Posts 177 Credits 430 From 广东深圳
Can this function be realized to replace English letters in a text file with the characters I want?

For example: I want to replace the letter R with "日" and r with "人", etc....

I can control that a certain letter is replaced with a specific character...

!!!!


[ Last edited by namejm on 2006-10-15 at 11:10 ]
Floor2 不得不爱 Posted 2006-10-15 10:48
超级版主 Posts 2,044 Credits 5,310 From 四川南充
What exactly do you want to replace?
Floor3 electronixtar Posted 2006-10-15 10:52
铂金会员 Posts 2,672 Credits 7,493
Use Notepad. If you need to use regular expressions, UltraEdit is sufficient.
Floor4 namejm Posted 2006-10-15 10:54
荣誉版主 Posts 1,737 Credits 5,226 From 成都
As long as you want to replace a certain letter with a specified character, it's all feasible under CMD - except for replacing it with sensitive characters. Please post the specific content you want to convert.

In addition, please don't make the font size too large. Although you may be in a hurry, too large a font size will take up too much space and cause inconvenience to the forum management.
Floor5 zouzhxi Posted 2006-10-15 11:05
中级用户 Posts 177 Credits 430 From 广东深圳
I want to replace the following characters


M1QJZSHQ200D00A01e01e00WCWB00WIBC00W01H00W02901A01B01D01A01901D01901E01A02B00D00A01e01e00WDe100WIBC00W01H00W02902K01F02K01B02K02b02M01F02B00D00ALBPC11CWBIBC00W01H00W02901B01B01801D01901901801G01F01D01701F01801A01B01G01E01902B00D00AF89IIcMY6N9W00W01H00W02902e02T02Z02d02N02e02M02B00D00AF89IIcIW2Fa500W01H00W02902e02T02Z02d02N02e02M02J02S02L02B00D00ADcMCGCM1FIYD00W01H00W02902e02T02Z02e02M02c02N01N01801D01A01502H02T02R02B


correspondingly with the following text


A=Ah a=A B=No b=Put C=Only c=Out ……
0=a 1=o 2=e 3=u 4=i 5=u 6=v 7=l 8=b 9=y


That's it. It's that simple...
Floor6 namejm Posted 2006-10-15 11:09
荣誉版主 Posts 1,737 Credits 5,226 From 成都
Please list out your alphabet conversion list completely. Without listing it out, I can't write the code.
Floor7 不得不爱 Posted 2006-10-15 11:10
超级版主 Posts 2,044 Credits 5,310 From 四川南充
Then you might as well use Notepad to complete it
Floor8 lxmxn Posted 2006-10-15 12:01
版主 Posts 4,938 Credits 11,386

  It is strongly recommended that the thread starter use Notepad or other third-party text editing tools to complete this task. If you use batch processing to solve it, this will cost a lot of brain cells.

 
  I hope the thread starter thinks twice.
Floor9 namejm Posted 2006-10-15 12:47
荣誉版主 Posts 1,737 Credits 5,226 From 成都
Actually, it is feasible to solve it with batch processing, and the efficiency is relatively high. For example, the following code can realize part of the functions of the 5th floor (because partial replacement will be executed multiple times and lead to inaccurate results, so some replacement rules are removed):
Floor10 redtek Posted 2006-10-15 21:42
金牌会员 Posts 1,147 Credits 2,902
Why does it seem like the code of the original poster is like the code of a self - created input method? Haha...

[ Last edited by redtek on 2006 - 10 - 15 at 21:43 ]
Floor11 zouzhxi Posted 2006-10-15 22:51
中级用户 Posts 177 Credits 430 From 广东深圳
TO redtek:
This is a file someone gave me. They told me that as long as I replace the letters and numbers inside with specific characters, I can find out what it is. I have no way either.

TO lxmxn:
You said to use Notepad. What if there are a lot (that is, more than the above. It's too tedious to replace one by one.)
Floor12 zouzhxi Posted 2006-10-15 23:10
中级用户 Posts 177 Credits 430 From 广东深圳
Originally posted by namejm at 2006-10-15 12:47:
Actually, it is feasible to solve it with batch processing, and the efficiency is relatively high. For example, the following code can realize part of the functions of the 5th floor (because partial replacement will be executed multiple times, resulting in inaccurate results,...

@echo off
cd.>2.txt
setlocal enabledelayedexpansion
for /f "delims=" %%i in (1.txt) do (
set var=%%i
set "var=!var:A=啊!"
set "var=!var:a=阿!"
set "var=!var:B=不!"
set "var=!var:b=把!"
set "var=!var:C=才!"
set "var=!var:c=出!"
set "var=!var:1=o!"
set "var=!var:2=e!"
set "var=!var:3=u!"
set "var=!var:4=i!"
set "var=!var:5=u!"
set "var=!var:6=v!"
set "var=!var:7=l!"
set "var=!var:9=y!"
>>2.txt echo !var!
)
start 2.txt






Why is there no case insensitivity when using it... How to solve this???

[ Last edited by zouzhxi on 2006-10-15 at 23:11 ]
Floor13 kingchain Posted 2006-10-15 23:55
初级用户 Posts 57 Credits 133
Floor14 无奈何 Posted 2006-10-16 00:08
荣誉版主 Posts 356 Credits 1,338
Your question is most suitable for the tr command under Linux & Unix. sed can also complete the function of tr. Try the following code:


Sed download address: http://www.student.northpark.edu/pemente/sed/gsed407x.zip
Floor15 zouzhxi Posted 2006-10-16 01:35
中级用户 Posts 177 Credits 430 From 广东深圳
I want to use batch processing to implement...!!!
1 2  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023