jrepl new

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
cesare
Posts: 5
Joined: 02 Dec 2019 08:08

jrepl new

#1 Post by cesare » 02 Dec 2019 08:23

Hi,

I'm trying to find and replace, in a txt file, this value: ,4, replace to ,2,

files contains line like this:
0001,4,0000000001,22,04/11/2016,01/01/0001 01:40:47,000035

i would like to check the part with ,4, anche change value to another number, ie ,1,.

jrepl " ¸4¸" " ¸1¸" /f test1.txt /o testnew.txt

any suggest?

thanks in advance.

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: jrepl new

#2 Post by aGerman » 02 Dec 2019 12:44

This will replace any occurrence of ",4," ...

Code: Select all

cmd /c jrepl.bat ",4," ",1," /f "test1.txt" /o "testnew.txt"
... while that would only replace occurrences of ",4," if the 4 is the second comma-separated token in a line.

Code: Select all

cmd /c jrepl.bat "([^,]*),4," "$1,1," /b /f "test1.txt" /o "testnew.txt"
Steffen

cesare
Posts: 5
Joined: 02 Dec 2019 08:08

Re: jrepl new

#3 Post by cesare » 03 Dec 2019 04:12

Thanks,

In my first test i wrote a command like the one you suggest:
cmd /c jrepl.bat ",4," ",1," /f "test1.txt" /o "testnew.txt"

but the result in txt file is something like this:
0001,1,0000000001,22,04/11/2016,01/01/0001 01:40:47,000035
਍   ㄀Ⰰ㄀Ⰰ         ㄀Ⰰ㈀㈀Ⰰ 㐀⼀㄀㄀⼀㈀ ㄀㘀Ⰰ ㄀⼀ ㄀⼀   ㄀ ㄀㔀㨀㌀㔀㨀㄀㤀Ⰰ    ㌀㌀ഀഀ
0001,1,0000000002,22,04/11/2016,01/01/0001 15:43:10,000033
਍   ㄀Ⰰ㄀Ⰰ         ㌀Ⰰ㈀㈀Ⰰ 㐀⼀㄀㄀⼀㈀ ㄀㘀Ⰰ ㄀⼀ ㄀⼀   ㄀ ㄀㔀㨀㐀㔀㨀㄀㘀Ⰰ    ㌀㔀ഀഀ
0001,1,0000000002,22,04/11/2016,01/01/0001 16:58:58,000033
਍ഀ

that's why i think is a comma problem and change the cl to the other one i wrote, without results.

cesare

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: jrepl new

#4 Post by aGerman » 03 Dec 2019 05:29

Umm, no. That's rather an encoding problem of your file. Your output looks a little like UTF-16. Try to shorten the file to a few lines, put it into a ZIP archive and upload it here. Probably we are able to find the culprit if we see original data.

Steffen

cesare
Posts: 5
Joined: 02 Dec 2019 08:08

Re: jrepl new

#5 Post by cesare » 03 Dec 2019 07:00

Hi, i try with only two lines but nothing change.

in attach you can see starter file.

Thanks.

Cesare
Attachments
test1.zip
(231 Bytes) Downloaded 322 times

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: jrepl new

#6 Post by aGerman » 03 Dec 2019 07:26

Exactly as I expected. The encoding is UTF-16 Little Endian with a Byte Order Mark.
Update your code like that:

Code: Select all

cmd /c jrepl.bat ",4," ",1," /f "test1.txt|UTF-16" /o "testnew.txt|UTF-16"
Or for my second proposal above, respectively.

Steffen

dbenham
Expert
Posts: 2461
Joined: 12 Feb 2011 21:02
Location: United States (east coast)

Re: jrepl new

#7 Post by dbenham » 03 Dec 2019 09:27

Steffen's suggestion of adding |UTF-16 to the file names uses ADO, which is fine.

Another option is to use the /UTF option to take advantage of CSCRIPT's native ability to read UTF-16. It should be marginally faster.

Code: Select all

cmd /c jrepl.bat ",4," ",1," /utf /f "test1.txt" /o "testnew.txt"

Dave Benham

cesare
Posts: 5
Joined: 02 Dec 2019 08:08

Re: jrepl new

#8 Post by cesare » 04 Dec 2019 11:17

many thanks, tomorrow i'll try.

Cesare

cesare
Posts: 5
Joined: 02 Dec 2019 08:08

Re: jrepl new

#9 Post by cesare » 07 Dec 2019 03:33

thanks, works fine.

Post Reply