Creating one file out of many, including the filename

J

John Nurick

Ummmm....is there a way to concatenate by the date the files were created

Do you mean only concatenate files created on a certain date (if so,
just move all other files out of the folder); concatenate files in date
order; include the date as well as the file name in each record; or
something else?

For that matter, do you mean the date the file was created, or the date
the file was last modified? You can get the latter by using something
like this

Dim strTimeStamp As String
...
strTimeStamp = Format(FileDateTime(TheFolder & strFN), "yyyy-mm-dd")

The "strTimeStamp = "line must be inserted in the code after the
existing line
Do While Len(strFN) > 0 'loop through all files
but before you open the file with
Open TheFolder & strFN For Input As #lngIn

Having got the date, add it to the
Print #lngOut
line, making sure to include a separating comma between it and the next
field.

and
leave the file extension off?

Do it just before you enclose the filename in quotes:

'chop off the file extension (which is in FileSpec)
strFN = Left(strFN, Len(strFN) - Len(FileSpec))
'enclose file name in quotes
strFN = """" & strFN & ""","
 
G

Guest

Awesome! Thanks again John

John Nurick said:
Do you mean only concatenate files created on a certain date (if so,
just move all other files out of the folder); concatenate files in date
order; include the date as well as the file name in each record; or
something else?

For that matter, do you mean the date the file was created, or the date
the file was last modified? You can get the latter by using something
like this

Dim strTimeStamp As String
...
strTimeStamp = Format(FileDateTime(TheFolder & strFN), "yyyy-mm-dd")

The "strTimeStamp = "line must be inserted in the code after the
existing line
Do While Len(strFN) > 0 'loop through all files
but before you open the file with
Open TheFolder & strFN For Input As #lngIn

Having got the date, add it to the
Print #lngOut
line, making sure to include a separating comma between it and the next
field.



Do it just before you enclose the filename in quotes:

'chop off the file extension (which is in FileSpec)
strFN = Left(strFN, Len(strFN) - Len(FileSpec))
'enclose file name in quotes
strFN = """" & strFN & ""","
 

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