Jason Yousef
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
http://box.net/huslayer
example.txt
Can you control the export from Crystal?
mlmcc
mlmcc
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
ASKER
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
all the lines needs to be shiffted and only started with the "ZE3......."
Thanks in advance for any help...
example2.txt
ASKER
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.Fi leSystemOb ject")
Set objInput = objFSO.OpenTextFile(strInp ut, ForReading, False, TriStateUseDefault)
arrText = Split(Replace(objInput.Rea dAll, Chr(34), ""), vbCrLf)
objInput.Close
Set objOutput = objFSO.OpenTextFile(strOut put, 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
Const ForReading = 1
Const ForWriting = 2
Const TriStateUseDefault = -2
strInput = "stix.txt"
strOutput = "stix" & ShortDateTime(Now) & ".txt"
Set objFSO = CreateObject("Scripting.Fi
Set objInput = objFSO.OpenTextFile(strInp
arrText = Split(Replace(objInput.Rea
objInput.Close
Set objOutput = objFSO.OpenTextFile(strOut
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
ASKER
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
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
ASKER
Thanks
http://www.dostips.com/DtTipsStringManipulation.php#Snippets.Remove