中国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-06 08:34
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,255 / 31
Floor1 leo1984 Posted 2007-10-31 22:52
初级用户 Posts 43 Credits 96
I'm a newbie, just started trying to write this ^^"
I have a directory of text files, they are data text files from a forum program


The text uses as the separator

The text content is as follows:
流浪漢∥∥A handy tool for searching Japanese AV actress pictures∥http://image.baidu.jp/∥59.113.162.145∥2007/03/21 13:37∥54188@IMYF.COM∥

I want to use the 2007/03/21 13:37 time part in every text file, which must be on the first line, to change the text filename

As shown below:


But with the way I wrote it, I can't get it done. Which part did I write wrong?
Please give me some guidance, big brothers, many thanks ^^




[ Last edited by leo1984 on 2007-10-31 at 10:53 PM ]
Floor2 1112yuhua Posted 2007-10-31 23:07
初级用户 Posts 44 Credits 106
I see that in your picture it's “||” and not “//”
Floor3 abcd Posted 2007-10-31 23:16
银牌会员 Posts 739 Credits 1,436
Floor4 terse Posted 2007-11-01 01:43
银牌会员 Posts 946 Credits 2,404
I'm not quite clear on what you mean: if your text content is like in your picture, then it should be || rather than ∥. How about trying this?


[ Last edited by terse on 2007-11-1 at 02:00 AM ]
Floor5 zh159 Posted 2007-11-01 02:06
金牌会员 Posts 1,467 Credits 3,687
Modified the post above a bit (if it's ||, change ∥ to ^|, and set tokens=5 according to the position of the characters you need): it's recommended to test it first and only do it for real after it's correct


[ Last edited by zh159 on 2007-11-1 at 02:08 AM ]
Floor6 terse Posted 2007-11-01 02:30
银牌会员 Posts 946 Credits 2,404
Changed it again. Here I tested it based on what was posted, so it's tokens=6. Of course that's not important, the key thing is that it can process it. In the previous post I didn't notice it was the first line.
:流浪漢|| ||A handy tool for searching Japanese AV actress pictures||http://image.baidu.jp/||59.113.162.145||2007/03/20 13:37||54188@IMYF.COM||



[ Last edited by terse on 2007-11-1 at 02:59 AM ]
Floor7 leo1984 Posted 2007-11-01 05:31
初级用户 Posts 43 Credits 96
Looks like you really need logic to play with this stuff. Every big brother writes it differently, but they all work.
I still need to practice more, otherwise I'm practically making a joke of myself by coming here @@

1112yuhua
It really is ^^

abcd
Haha, big bro is awesome indeed, it worked as soon as I tested it. If you ever come to Taiwan, I definitely have to treat you to a meal ^^

terse
Both of your commands worked, as long as the parameters are changed to match what I need. I did test the first one, but some symbols weren't removed from the filename, so it became 2007/03/21 13:37.txt
Many thanks, big bro ^^
Floor8 abcd Posted 2007-11-01 07:25
银牌会员 Posts 739 Credits 1,436
∥ is one character, not two characters like //

The OP really gets up early too
Floor9 leo1984 Posted 2007-11-01 07:40
初级用户 Posts 43 Credits 96
Haha~ I was exhausted last night working on a website
so I went to sleep first, and got up earlier today ^^

Can I also ask something else? When I was changing the text filenames,
I found that it can't recognize the - character
So after renaming, it becomes 61.224.104.78 - 61.224.104.78.txt

But I don't need it to recognize the - character
I just want to turn 61.224.104.78 - 61.224.104.78 into 61.224.104.78

Before processing:

0o0∥1∥ Vista-style language bar & new sound icon & volume control interface∥It looks pretty good after installation, but it's in Simplified Chinese = =!!!, if I want to change it back how do I do it @0@???∥61.224.104.78 - 61.224.104.78∥2006/11/01 09:23∥zerg0517@yahoo.com.tw

After processing:

0o0∥1∥ Vista-style language bar & new sound icon & volume control interface∥It looks pretty good after installation, but it's in Simplified Chinese = =!!!, if I want to change it back how do I do it @0@???∥61.224.104.78∥2006/11/01 09:23∥zerg0517@yahoo.com.tw

I tried writing another for to grab and delete the characters between
∥61.224.104.78 - 61.224.104.78
but it all failed. How should this be written?

[ Last edited by leo1984 on 2007-11-1 at 07:43 AM ]
Floor10 abcd Posted 2007-11-01 08:11
银牌会员 Posts 739 Credits 1,436
If the number of ∥ before the IP is fixed, then the following should work.
Floor11 abcd Posted 2007-11-01 08:22
银牌会员 Posts 739 Credits 1,436


This is for cases where the count isn't fixed, but because the string contains the special character &, you have to add "" when outputting it.
Floor12 leo1984 Posted 2007-11-01 08:27
初级用户 Posts 43 Credits 96
Big bro, it seems it doesn't work
∥ really is a fixed count
- is also fixed

It looks like this loop is finding the character pair ∥- , right?
But when I tested it just now, there was no response @@

Also, big bro, haven't you gone to work or class yet?
Thanks for the enthusiastic help ^^
Floor13 leo1984 Posted 2007-11-01 08:29
初级用户 Posts 43 Credits 96
The command in the second section that you gave says

This time < should not appear

What does that mean @@?
Floor14 abcd Posted 2007-11-01 08:29
银牌会员 Posts 739 Credits 1,436


Using sed is much faster
Floor15 abcd Posted 2007-11-01 08:31
银牌会员 Posts 739 Credits 1,436
Because I copied this section into Notepad to process it:
"0o0∥1∥ Vista-style language bar & new sound icon & volume control interface∥It looks pretty good after installation, but it's in Simplified Chinese = =!!!, if I want to change it back how do I do it @0@???∥61.224.104.78 - 61.224.104.78∥2006/11/01 09:23∥zerg0517@yahoo.com.tw∥“

I tested every section, and it works on my side.
1 2 3  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023