What program created the DAT files?
I assume you mean files with a .dat file extension which is a pretty nondescript extension - could be any format...
It is a big dataset with .dat extension files containing html tags. In each file we have set of documents which I want to extract each as a separate html file. I have no idea what program created the files.
Assuming each document starts with a unique HTML tag and ends with one as well this would be very easy to do. All you have to do is parse the file looking for the start tag, write the data out to a new file until you reach the end tag, rinse and repeat.
I've done this in QuickBASIC 4.5, PDS 7.0, Visual BASIC and once even using the BASIC Stamp 2 with a Memory Stick Datalogger to exract GPS information from a KML file.
I've also done this to update/upgrade one file set to match another (formatting).
Assuming each document starts with a unique HTML tag and ends with one as well this would be very easy to do. All you have to do is parse the file looking for the start tag, write the data out to a new file until you reach the end tag, rinse and repeat.
I've done this in QuickBASIC 4.5, PDS 7.0, Visual BASIC and once even using the BASIC Stamp 2 with a Memory Stick Datalogger to exract GPS information from a KML file.
I've also done this to update/upgrade one file set to match another (formatting).
You could also do this with a .vbs (visual basic script) utilizing the FileSystemObject TextStream object. The script can be created with Notepad. Just double click the .vbs file to execute the script...
Here is a little script to get you started - it lists cookie exceptions from Chrome settings:
option explicit
Const TemporaryFolder = 2
Const ForWriting = 2
Const ForReading = 1
Const TristateFalse = 0
Const TristateTrue = -1
Const TristateUseDefault = -2
Const pattrn = """pattern_pairs"":{"
' Const pattrn2 = """automatic_downloads"":{"
Const pattrn2 = """automatic_downloads"":{},""cookies"":{"
dim WSHShell, fso, ts, UserProfile, PrefsFldr, ChromePrefs
dim shell
set shell = CreateObject("Shell.Application")
Set WSHShell = WScript.CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
UserProfile = WSHShell.ExpandEnvironmentStrings("%UserProfile%")
' PrefsFldr = fso.BuildPath(UserProfile, "\Local Settings\Application Data\Google\Chrome\User Data\Default\Preferences")
PrefsFldr = fso.BuildPath(UserProfile, "AppData\Local\Google\Chrome\User Data\Default\Preferences")
' "C:\Users\Ron Czapala\AppData\Local\Google\Chrome\User Data\Default\Preferences"
If fso.FileExists(PrefsFldr) Then
GetPrefs
else
msgbox PrefsFldr,vbcritical, "Not found"
end if
Public Sub GetPrefs()
dim idx, idy, msg, xcepts, i, mydocs, xfile, xts
Set ts = fso.OpenTextFile(PrefsFldr, ForReading, False, TristateFalse)
ChromePrefs = ts.ReadAll
' msgbox len(ChromePrefs)
ts.Close
mydocs = WshShell.SpecialFolders("MyDocuments")
xfile = fso.BuildPath(mydocs, "Exceptions.htm")
set xts = fso.CreateTextFile(xfile, True, False)
HTML1 xts
xts.writeline PrefsFldr & "<BR><HR>"
idx = InStr(1,ChromePrefs, pattrn2, vbTextCompare)
if idx > 0 then
ChromePrefs = Mid(ChromePrefs, idx + len(pattrn2)+1)
idx = InStr(1, ChromePrefs, "}}", vbTextCompare)
If idx > 0 Then
ChromePrefs = Mid(ChromePrefs, 1, idx + 1)
End If
' msgbox ChromePrefs
idy = InStr(idx, ChromePrefs, "[*.]")
xcepts = Split(ChromePrefs, "},""")
xts.writeline Ubound(xcepts) & " entries<BR>"
' for i = 0 to 5
' msgbox xcepts(i)
' next
' xts.writeline UBound(xcepts) & "<BR>"
For i = 0 To UBound(xcepts)
If InStr(xcepts(i), "[*.]") > 0 then
' If InStr(xcepts(i), """cookies"":") > 0 Then
If InStr(xcepts(i), """setting"":") > 0 Then
xts.writeline Process_Entry(xcepts(i)) & "<BR>"
End If
End If
Next
Else
Msgbox pattrn & " not found",vbCritical,"Error"
End If
HTML2 xts
xts.close
shell.Open xfile
End Sub
Private Sub HTML1(xts)
xts.write "<HTML><head><title>Chrome Cookie Exceptions</title>" & vbcrlf
xts.write "</head>" & vbcrlf
xts.write "<body>" & vbcrlf
xts.write "<font color='navy' style=' FONT-FAMILY: Verdana, Tahoma; FONT-SIZE: 12px'>"
End sub
Private Sub HTML2(xts)
xts.write "</font>"
xts.write "</Body>" & vbcrlf & "</HTML>"
End sub
Private Function Process_Entry(entry)
Dim idx, idy
Dim retval, cval
retval = Replace(entry, "[*.]", "")
' msgbox retval
' idy = InStr(retval, "cookies" & chr(34) & ":") + 9
idy = InStr(retval, "setting" & chr(34) & ":") + 9
cval = mid(retval, idy, 1)
if cval = "1" then
cval = "Allow"
end if
idx = InStr(retval, ",")
on error resume next
retval = Left(retval, idx - 1)
if err.number <> 0 then
msgbox entry,,idx
Process_Entry = entry
else
Process_Entry = cval & " " & retval
end if
End Function
Comments
I assume you mean files with a .dat file extension which is a pretty nondescript extension - could be any format...
We can't help without some details.
I've done this in QuickBASIC 4.5, PDS 7.0, Visual BASIC and once even using the BASIC Stamp 2 with a Memory Stick Datalogger to exract GPS information from a KML file.
I've also done this to update/upgrade one file set to match another (formatting).
You could also do this with a .vbs (visual basic script) utilizing the FileSystemObject TextStream object. The script can be created with Notepad. Just double click the .vbs file to execute the script...
Here is a little script to get you started - it lists cookie exceptions from Chrome settings: