Link to home
Start Free TrialLog in
Avatar of Jason Yousef
Jason YousefFlag for United States of America

asked on

help creating a batch file to automate removal of double quotes and clean a text file

Hello, I need some help creating a batch file to automate the process of removeing double quotes in 2 text file, it gets exported from crystal reports, can be renamed any name. the double quotes are in the beggining of the files, middle and at the end of the files. also need to removes 2 spaces to join two lines into one line. output file needs to have a different name , such as today's date, so it's doesnt get overwritten. example is attached in the text file. this should be ONE line and all the quotations are removed.

http://box.net/huslayer 

 


example.txt
Avatar of Patmac951
Patmac951
Flag of United States of America image

It would be easier to simply write a quick program to do this but if you have to use a batch file, this link should provide you with the necessary command syntax you need to accomplish this.
http://www.dostips.com/DtTipsStringManipulation.php#Snippets.Remove
Avatar of Mike McCracken
Mike McCracken

Can you control the export from Crystal?

mlmcc
ASKER CERTIFIED SOLUTION
Avatar of Shift-3
Shift-3
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jason Yousef

ASKER


Shift-3,

Thank you so much, that worked great, but it joined all the lines together, even the next records, it basically removed all the spaces, but the example files was having only one record, so when i run it on the actual file,it joined all the lines.

is there a way we can join the only first 2 lines, and each new line starts with the "ZE3" ?

Thank you so much for your help
appreciate your help
This is another example, i've included more than 1 record, sorry if the other one was a misleading example.
 
all the lines needs to be shiffted and only started with the "ZE3......."
 
Thanks in advance for any help...

example2.txt
I've been able to get help from a friend modifying Shift-3  code to this :
 

Const ForReading = 1
Const ForWriting = 2
Const TriStateUseDefault = -2
strInput = "stix.txt"
strOutput = "stix" & ShortDateTime(Now) & ".txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objInput = objFSO.OpenTextFile(strInput, ForReading, False, TriStateUseDefault)
arrText = Split(Replace(objInput.ReadAll, Chr(34), ""), vbCrLf)
objInput.Close
Set objOutput = objFSO.OpenTextFile(strOutput, ForWriting, True)
For i = 0 TO UBound(arrText) - 1 Step 2
  objOutput.WriteLine arrText(i) & arrText(i + 1)
Next
objOutput.Close
Function ShortDateTime(dtmTime)
  strYear = Year(dtmTime)
  strMonth = Right("0" & Month(dtmTime), 2)
  strDay = Right("0" & Day(dtmTime), 2)
  strHour = Right("0" & Hour(dtmTime), 2)
  strMinute = Right("0" & Minute(dtmTime), 2)
  strSecond = Right("0" & Second(dtmTime), 2)
  ShortDateTime = strYear & strMonth & strDay & "-" & strHour & strMinute & strSecond
End Function
 
 
my only concern that i don't understand the difference or the addition i mean...can you explain it please when you have a chance...

the reason i'm asking is I've a different report that comes in 5 lines this time!!!

i'll post example for the file  "EXAMPLE3.TXT"

Thanks again sooooooooooo much Shift-3, you're the best
 
Sorry that was a stupid question...
It's easier than what i thought
 
For i = 0 TO UBound(arrText) - 4 Step 5
  objOutput.WriteLine arrText(i) & arrText(i + 1) & arrText(i + 2) & arrText(i + 3) & arrText(i + 4)
Next

 
lol, thanks for everybody that tried to help or even looked at my question
Shift-3 thanks a zillionnnnnn
Thanks