I need to parse a file using windows batch scripts and replace all occurences of backspace (^H) with any other delimiter like tab. I searched in several forums but couldn't find a proper solution. Any ideas are most welcome.
+1
A:
This can't be using pure batch syntax. I think you're best of using a command line program like this one: FART.
Pekka
2009-12-30 22:49:49
HAHAHAHA FART +1
Hamish Grubijan
2009-12-30 22:55:42
I am trying to use "fart expdata.dat \b K". Basically I am trying to find a backspace character in my file expdata.dat and replace it with 'K'. But fart is not able to do it. It gives the following message"Replaced 0 occurence(s) in 0 file(s)."How to put a backspace in a file? I tried to put it by pressing the backspace key in my keybaord. That goes and deletes a character in the file but I am expecting that now my file contains a backspace character.
Harsha
2009-12-30 23:06:49
Odd, it seems to be able to handle backspaces, and seems to resolve them in the source code. You could try putting the character into quotes, and try a double backspace \\b. Are you doing this directly from the command line? If it doesn't work when called directly from command line, I'm afraid you'll have to find another tool.
Pekka
2009-12-30 23:13:05
And have you tried fart's verbose mode?
Pekka
2009-12-30 23:32:17
Yes I tried by giving the following command :fart -V expdata.dat "\b" Kand the output I got is :FART: --verboseFART: wild_card="expdata.dat"FART: find_string="\b"FART: replace_string="K"FART: processing ,expdata.datReplaced 0 occurence(s) in 0 file(s).
Harsha
2009-12-30 23:48:58
How to put a backspace character in file? How does it look?
Harsha
2009-12-31 00:05:44
The \b should do just fine, there is probably no other way to type in a backspace. You are 100% sure there are backspace characters in the file? Can you try a file with different characters like tabulators?
Pekka
2009-12-31 00:11:09
I am able to do it now using the following:fart -V -B -C --backup myfile.txt \b KDo you know of any way to parse such a file using bcp tool ?
Harsha
2009-12-31 01:49:43
What does the backup switch in fart do?
Pekka
2009-12-31 14:58:25
Since this is a binary file, fart does not make changes to it without the --backup option.
Harsha
2009-12-31 19:13:52
I see. No, I don't know how to parse those files, sorry. If FART doesn't work out for you here is another question with a few pointers: http://stackoverflow.com/questions/60034/how-can-you-find-and-replace-text-in-a-file-using-the-windows-command-line-enviro I don't know which ones work with backspaces, you'd have to test.
Pekka
2009-12-31 20:24:13