get last line in text file

K

Krazy Darcy

As I'm using call shell(xcopy... to copy files between internal and external
hard drives (online backup) I can generate a text file that lists all the
files copied.

I assume the following is more of a programming than inport question.

Here is the end of the file for my "photo library" folder

H:\photo-library\people\UM\posskeep\08-06-20\IM000075.JPG
H:\photo-library\people\UM\posskeep\08-06-20\Thumbs.db
5694 File(s) copied

What I want to do is take the last line and use it to update a field in a
table (and replace the previous data in that field) This is so I know it
completed properly.

The length of this fil will increase as the photo library grows so anything
that says copy line 5686 will not work.

Is there any way of doing this?

Thanks.
 
K

Krazy Darcy

Thanks.
This is the one I got from the link you provided me with.there

Private Sub Form_Open(Cancel As Integer)

'// = = = = = = = = = = = = = = = = =
'// By Dana DeLouis
'// = = = = = = = = = = = = = = = = =
Dim fso
Dim f
Dim t As Double 'Timer
Dim j As Long 'Loop counter
Dim s As String 'Dummy String
Dim NumberOfRecords As Long
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Const nLines = 10
Const File = "C:\dw\logs\temp.txt"
t = Timer
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso_OpenTextFile("c:\dw\logs\buallgfxlib.txt", ForAppending)
NumberOfRecords = f.Line - 1
f.Close
Set f = fso_OpenTextFile("c:\dw\logs\buallgfxlib.txt", ForReading)
For j = 1 To NumberOfRecords - nLines
s = f.SkipLine
Next
'You could put the rest into an Array
'v = Split((f.readall), vbLf)
For j = 1 To nLines
Debug.Print f.ReadLine
Next
f.Close
Set f = Nothing
Set fso = Nothing

Debug.Print
Debug.Print Timer - t & " Seconds!"
End Sub

I changed the filenames to suit but it doesn't seem to do anything
c:\dw\logs\buallgfxlib.txt is the textfile (one of 6) that I want to read
the last line from
I then want to put it into a table and put the date modified into it as
well. If it is done as a new record then I will have to have a field for
file name (or use 6 tables).

I assumed
Const File = "C:\dw\logs\temp.txt" was an output file but this doesn't seem
to appear or be created

My vb knowledge while growing is currently shallower than the depth of this
code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top