![]() |
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-06 08:35 |
48,039 topics / 350,124 posts / today 0 new / 48,251 members |
| DOS批处理 & 脚本技术(批处理室) » [Help] Where is the mistake in the text replacement/renaming script I wrote? (with image) |
| Printable Version 2,257 / 31 |
| Floor16 abcd | Posted 2007-11-01 08:35 |
| 银牌会员 Posts 739 Credits 1,436 | |
| Floor17 leo1984 | Posted 2007-11-01 08:41 |
| 初级用户 Posts 43 Credits 96 | |
|
Strange
Big bro, still no response on my side I repeatedly tested all three sections of the commands you gave, and still there was no response at all @@ You said yours works but I'm sure mine gives no response at all I have sed installed too Also, I just found another batch file site ^^ http://bbs.verybat.cn/ |
|
| Floor18 abcd | Posted 2007-11-01 08:44 |
| 银牌会员 Posts 739 Credits 1,436 | |
|
o(∩_∩)o... mine only displays the result, it doesn't modify the file.
|
|
| Floor19 abcd | Posted 2007-11-01 08:47 |
| 银牌会员 Posts 739 Credits 1,436 | |
|
There's also www.mybat.cn. These three batch-processing sites are relatively well-known domestic batch-processing sites
But the other two still can't compare to cn-dos. |
|
| Floor20 leo1984 | Posted 2007-11-01 08:51 |
| 初级用户 Posts 43 Credits 96 | |
|
I'm using ExeScript V3.0.0_ a tool for converting bat to exe http://mmm.onegreen.net/soft4/ExeScript-v3.0.rar
Because I have Kaspersky antivirus software installed so I convert bat into exe Could there be a difference because of this? But the commands you gave before all ran while this time there's absolutely no response @@ I'll try writing it myself and see @@ |
|
| Floor21 abcd | Posted 2007-11-01 09:01 |
| 银牌会员 Posts 739 Credits 1,436 | |
|
I also have Kaspersky installed.
It probably isn't this issue. The problem may be that your file is non-ANSI. |
|
| Floor22 leo1984 | Posted 2007-11-01 09:22 |
| 初级用户 Posts 43 Credits 96 | |
|
What you wrote does indeed output the correct result, but it doesn't modify the text itself
But I need to modify the text itself I just combined big bro zh159's with your command @echo off md Temp for /f "delims=" %%f in ('dir /on/b "*.txt"') do ( echo.>Temp\%%~nf.txt for /f "tokens=1,2,3,4,5,6,7,8 delims=∥-" %%i in (%%f) do echo %%i∥%%j∥%%k∥%%l∥%%m∥%%o∥%%p∥>>Temp\%%~nf.txt ) pause and I wrote it successfully This newbie finally managed to write one successfully ^^ Thank you for helping me grow I'm so touched Usually I just play with some cgi and php. After getting used to those commands, looking at dos and learning in an unfamiliar area feels especially difficult >< Even though I only did a simple adaptation, your enthusiastic help, big bro, is already a huge step in helping me learn! [ Last edited by leo1984 on 2007-11-1 at 09:27 AM ] |
|
| Floor23 abcd | Posted 2007-11-01 09:31 |
| 银牌会员 Posts 739 Credits 1,436 | |
|
o(∩_∩)o... generally I don't modify files, I just let the OP see the effect
To modify a file, you just need to export it to a file. |
|
| Floor24 terse | Posted 2007-11-01 10:44 |
| 银牌会员 Posts 946 Credits 2,404 | |
|
Just now I used the 3 batch solutions from posts #4, #5, and #6 to test filenames with spaces. #4 and #5 both failed. If the file contents have repeated formats, then #4 also can't name it using the first line's content.
The one in post #6 passed all the above tests! SED really does seem easier to use for this! |
|
| Floor25 leo1984 | Posted 2007-11-01 11:14 |
| 初级用户 Posts 43 Credits 96 | |
|
That's true indeed
I just tested the one I wrote myself, and if it encounters a case without the - symbol, it deletes the IP string For sed "s/\([0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\) - \1/\1/" how should it be output? It seems it can't be added into a bat command @@ |
|
| Floor26 abcd | Posted 2007-11-01 11:17 |
| 银牌会员 Posts 739 Credits 1,436 | |
|
Just add a regex and it will only process lines that contain -. |
|
| Floor27 leo1984 | Posted 2007-11-01 11:24 |
| 初级用户 Posts 43 Credits 96 | |
|
Big bro,
you know I'm processing the text files in a whole directory The sed command doesn't seem to have either a loop or variables so it especially leaves little bro totally confused How do I process the text files in the whole directory and output them? Thanks, big bro >< |
|
| Floor28 abcd | Posted 2007-11-01 11:27 |
| 银牌会员 Posts 739 Credits 1,436 | |
|
Modified from yours |
|
| Floor29 leo1984 | Posted 2007-11-01 11:34 |
| 初级用户 Posts 43 Credits 96 | |
|
sed really is extremely precise
It can directly specify exactly which characters to modify Unlike bat, where you have to lay out an array to make changes When the two are combined, you can achieve effects comparable to VB software programs Looks like besides learning bat, I also need to learn sed The fire of learning in me is burning now >< Thanks, big bro! The world only moves forward because of people like you [ Last edited by leo1984 on 2007-11-1 at 11:35 AM ] |
|
| Floor30 abcd | Posted 2007-11-01 11:47 |
| 银牌会员 Posts 739 Credits 1,436 | |
|
It's not just the sed command, there are many others too; awk or gawk are even more powerful.
A lot of linux and unix commands really are very useful. |
|
| Prev 1 2 3 Next |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |