Looping through files

Hi,

I am trying to loop through a directory of (.txt) files.

What I would like to do is append the last 4 days (from today's date) worth 
of files into one file, and save that file for later processing.

Does anyone know or have the logic that I need to process these files?

Cheers,
GT
0
Utf
2/26/2008 3:00:00 AM
access 16762 articles. 3 followers. Follow

1 Replies
673 Views

Similar Articles

[PageSpeed] 44

Use Dir to loop through the files in a folder.

Here's a very simple example of appending them to an array:
    http://allenbrowne.com/func-02.html

Use FileDateTime() to test if they are in the last 4 days; presumably you 
don't add the old ones to your array.

I think you want to write the file names to a text file? If so, see help (in 
the VBA window) on Open. You will Open For Output, and Print # to write each 
line.

-- 
Allen Browne - Microsoft MVP.  Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"GLT" <GLT@discussions.microsoft.com> wrote in message
news:84E51989-19BD-4EDA-A5EC-BBE14474F891@microsoft.com...
>
> I am trying to loop through a directory of (.txt) files.
>
> What I would like to do is append the last 4 days (from today's date) 
> worth
> of files into one file, and save that file for later processing.
>
> Does anyone know or have the logic that I need to process these files? 

0
Allen
2/26/2008 3:15:40 AM
Reply:

Similar Artilces:

Repost: Loop through files
I posted this earlier, but it never made it to the screen so I'm reposting - hope it doesn't duplicate the earlier one. I need to loop through all currently open workbooks and display a message box that tells me the file name and whether or not the workbook is visible. Your example code is what I need. Thanks in advance for your assistance. Hi, Sub ShowThem() Dim oBook As Workbook For Each oBook In Workbooks MsgBox "Book " & vbNewLine & oBook.FullName _ & vbNewLine & "is " & _ IIf(oBook.Windows(1).Visible...

Large excel file is very slow
We have a few excel files. These files are about 25 Mb each. When we want to open a file, it takes about 3 minutes to open it. When we want to save these files it takes about 5 minutes. We try different files on different pc's. So it's not the fil itselves. Does anyone have a solution or explanation for this. Thx GT -- Message posted from http://www.ExcelForum.com Check out this site's You can use Rob Bovey's Code cleaner to clean up your code http://www.appspro.com/utilities/utilities.asp Opening/Saving Bottlenecks (Charles Williams) http://www.decisionmodels.com/op...

CreateFile for opening a file
Hello! I'm trying to use CreateFile to open a file for reading *without* locking it! Since English isn't my native tongue I don't get the documentation of the dwShareMode. What should I set dwShareMode to that will not lock the file? // Anders -- This is what I have today, which don't work! hfile = CreateFile ( m_szFilename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); Anders Eriksson wrote: > I'm trying to use CreateFile to open a file for reading *without* > locking it! Since English isn't ...

can you edit a print shop file in publisher?
Is the print shop software compatible with MS Publisher. No, it is not compatible. You could export your printshop item as an image and insert that image into Publisher, but you will only be able to edit the image as an image, you won't be able to edit text, etc. -- Brian Kvalheim Microsoft Publisher MVP http://www.publishermvps.com This posting is provided "AS IS" with no warranties, and confers no rights. "Tthomas" <Tthomas@discussions.microsoft.com> wrote in message news:96D872CD-E940-4891-86F9-23F0E21CC8F2@microsoft.com... > Is the print shop softwa...

FIle Path
What is the VBA code to return a currently open workbook's directory? Manu Thanks Activeworkbook.Path -- HTH RP (remove nothere from the email address if mailing direct) "DJH" <dhdotymel@cox.net> wrote in message news:wwKIe.2899$HM1.1257@okepread03... > What is the VBA code to return a currently open workbook's directory? > > Manu Thanks > > ...

Money 98 File won't import to Money 2002, 2003 or 2004
I use Money 98 daily without any problem. (Windows XP) However, when I try to open a Money 98 data file in a newer version of Money, it churns for a while and then I get an error message: "Microsoft Money has encountered a problem and needs to close. We're sorry for the inconvience." All version of Money are US, so that's not the issue. Any other suggestions? I'd really like to get off of Money 98, but I can't afford to lose all my historical data.... Assuming you can open the sample file in the later versions: KB 182608,274584,178830 >-----Or...

Can file arrival trigger message to start app. program??
Hi, I've debated where to post this and have decided to start here. I didn't see a "general discussions" group. If there's a better group - let me know. The OS is Windows Server 2003 latest packs. The apps are written in VC++. Shortly the will undergo the "conversion" to .NET 2005 from VS6. Future apps may be written in C#. At this point I am thinking conceptually, not exact technical, i.e is this even possible? The question: Is there a way for a file's arrival on a drive share to trigger a message to another server to start up an application to ...

File location changes after saving file
I'm reposting here at the suggestion of a Windows 7 forum moderator who thought my situation a problem with Word not Windows: When working on projects, I group together relevant files in areas of my desktop. However, with Word 2007 on Windows 7 (as opposed to Word and Windows 2000), when I save a file that's on the desktop, the file location that was the docx file becomes the wbk file and the docx file is put in the first open slot in the rank of files on the left-hand of the desktop. Thus, if <file.docx> was in the upper right quadrant, after saving the newer ...

Combine MFC with non-MFC files?
Hi, I met a problem... When I try to use a non-MFC cpp file into my MFC project, I remove the "Use precompiled header" setting to avoid include stdafx.h. All files compiled ok. But when linking, it returned some error message: Linking... uafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) already defined in libcpmtd.lib(newop.obj) uafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in LIBCMTD.lib(dbgdel.obj) uafxcwd.lib(afxmem.obj) : error LNK2005: "...

Open File Dialog
I am modifying an application that allows the user to add files to a list box and will then process these files. I need the list box to fill with files on loading and then be able to launch a CFileDialog box. For reasons unknown unless you launch the CFileDialog object first then fill the box with the rest of the list the CFileDialog box will not launch. I am looking for suggestions or a reason that this is happening..... >I am modifying an application that allows the user to add >files to a list box and will then process these files. I >need the list box to fill with files...

All Office 2000 and 2007 Excel and Word files open very slowly
If I open a Excel or Word file from a folder it takes a good 15 seconds for the file to open. If I start Word or Excel first and then do a file, open, the file will open instantly. I dowloaded the trial version of Office 2007 after this started with my Office 2000 and 2007 does it as well. I have removed and reinstalled Office 2000 and re-downloaded all SP's and updates. Have you cleared your TIF folder and Temp folders lately? Gord Dibben MS Excel MVP On Sun, 14 Oct 2007 09:04:01 -0700, thecloak <thecloak@discussions.microsoft.com> wrote: >If I open a Excel or Word file...

How to place an excel file in "Favorites"
In Microsoft 2000 Professional how can I place an Excel file in my "Favorites. Hi bobs Dana DeLouis posted this ********************** Using File | Save As... does not work well. So, use File : Open... Select the History tab on the left. The file you are working on should be in this list. Select your file name here. Then, on the upper right of the Open dialog, select "Tools", and select "Add to Favorites." HTH Dana DeLouis -- Regards Ron de Bruin http://www.rondebruin.nl "Bobs Walk" <Bobs Walk@discussions.microsoft.com> wrote in message ne...

convert unicode .pst files to non-unicode files
I have Outlook 2003 and I have been inputing colleges in separate contact files so that I can transfer these files to other programs i.e. access, excel, outlook 2002 and earlier but when I export the .pst files(unicode files) and try to import them into a program like outlook 2002, it states that an error will occur in data transfer. How do you convert unicode files to non-unicode files so that outher programs can use them? There is a help file titled non-unicode to unicode but that doesn't help. Thanks You can't convert existing Unicode .PST files to the earlier ANSI versi...

My "Do While...Loop" wont loop and delete the spaces between my digits.
I am trying to eliminate the spaces between digits in Australian Business Numbers which have the format "NN NNN NNN NNN" to produce an eleven digit number with no spaces. I have written a function to do this that appears to work. I now want to call this function from a subroutine to change about 3000 numbers. The subroutine is causing me headaches. Here is my space-eliminating function: Function RemoveSpaces(CellContents As String) As String Do While InStr(1, CellContents, " ") > 0 CellContents = Replace(CellContents, " ", "") Loop Re...

Re: Where should be the best place to stored Applcation Data Files?
"Giovanni Dicanio" <gdicanio@_NOSPAM_email_DOT_it> ha scritto nel messaggio news:... > BTW: this post by John Robbins is very interesting reading: > http://www.wintellect.com/CS/blogs/jrobbins/default.aspx copy-and-pasto - the correct link is this: http://www.wintellect.com/CS/blogs/jrobbins/archive/2008/07/10/in-defense-of-vista-and-the-challenges-facing-windows-7.aspx Giovanni And then there's this Vista security discussion from last Friday (cool date, 8/8/8): http://it.slashdot.org/article.pl?sid=08/08/08/1155208 -GB On Fri, 8 Aug 2008 18:50:23 +0200, ...

delete log files
have a filled up drive- no need for logfiles in this instance circumstance would allow circular logging for next few months, before setting though, need to reclaim space on hdd. how to tell which logfiles I can delete and not hose the db? In news:14ABD827-B264-4626-8970-20E5578A4053@microsoft.com, AlexandrDiogenes@hotmail.com <AlexandrDiogeneshotmailcom@discussions.microsoft.com> typed: > have a filled up drive- no need for logfiles in this instance > circumstance would allow circular logging for next few months, before > setting though, need to reclaim space on hdd. how ...

Make Excel upload files via FTP??
A few days ago I asked about creating files from a Excel worksheet that can be shared online. Someone suggested this VBA: http://www.meadinkent.co.uk/xladvhtml.htm I've been trying this and it works. Now I want to get Excel to run the VBA-code every time the file is closed, AND (and now comes the tricky part), to upload the created html-files to a FTP account. Every time the file is closed the macro "make_htm" should run, and get the files got created upload from the local folder, to a FTP account. Is this possible?? ...

Loop?
I really am having a bad week... I have a workbook with two sheets; 'main' & 'not complete'. On the main sheet I have 10 columns of data, row 2 to 20 (More rows can be added so may be more). What I need to do is: for each row, if column I = 1 and J = "" then I need to copy some of the data from that row (column A,B,F & G) to the sheet called 'not complete'. the cell in column J will then be changed to 1. Repeat for each row making sure the sheet called 'not complete' does not have any blank rows. Hope that makes sense a...

Opening an excel file
I used to be able to double-click on an excel file and it would open automatically. Now, all of a sudden, when a double-click an excel file, only the application opens and I need to then browse and open the file. I find this to be a nuisance. How can I return to double-clicking to open a file? -- M.L. Do you have other excel files open at the time or does this happen when opening the first one? Mel;670895 Wrote: > I used to be able to double-click on an excel file and it would open automatically. Now, all of a sudden, when a double-click an excel file, only t...

Loop/Repeat Code
A2007 I need to run code while the record is displayed on a form, and must run this for all records. I have on the Click event of a button on the form: DoCmd.GoToRecord , "", acFirst Call MyFunction It is MyFunction I need help with: DoCmd 'Run some code and queries' DoCmd.GoToRecord , "", acNext Need help here to repeat/loop until the last record. Thanks in advance. ...

Office Files get corrupted
At home I am running OSX 10.3.2 on both a dual 1.8 G5 and a G4 powerbook. I am using OFfice X and my files keep getting corrupted and I office does not recognize them as office files. At work I have office XP and run XP pro. I use these same files on both platfoms and but mor eoften than not the file corrupts and neither my PCs or my MACs can open them Can anyone help? In article <dab581ef.0407102312.c368056@posting.google.com>, gkef90@yahoo.com (glk) wrote: > At home I am running OSX 10.3.2 on both a dual 1.8 G5 and a G4 > powerbook. I am using OFfice X and my files keep get...

PST file is in use
I have a .pst file in Outlook that I move my e-mails to for safe keeping. I have accessed this file in Outlook for months. Now I cannot access it. I a message that the file "is in use and could not be accessed. Close any application that is using the file, and then try again." The file is not in use by anyone. Does anyone hav a solution to this problem. Your help will be greatly appreciated. Myra Myra <anonymous@discussions.microsoft.com> wrote: > I have a .pst file in Outlook that I move my e-mails to > for safe keeping. I have accessed this file in Outl...

need MSOE.DLL file
Hubby deleted stuff and Outlook Express won't function without this file!!! HELP!!! ...

Can't create file....
Hi I have a user that gets the following error only on some emails... "Can't create file resume.doc - right click the folder you want to create the file in and then click properties on the shortcut menu to check your permissions for the folder. " In this case there were 2 word docs. and only the one gave the error? I have emptied the TEMP folder, but same problem still. Any ideas please. Thanks Gabriel <gabriel@kiwioutsourceit.co.nz> wrote: > I have a user that gets the following error only on some emails... > "Can't create file resume.doc - right cli...

File path in a hyperlink field
Using Access XP. I have a form with a hyperlink field. The default value for the filed is the path where the files are at (X:\Marketing\Images) this is a drive in the server where the marketing people put different images associated with a record. No problem opening the image file or hyperlinking. My question is: Can the user type only the file name, without X:\Marketing\Images showing on the screen? For example: they type: "Logo.bmp" and the hyperlink field actually contains: X:\Marketing\Images\Logo.bmp. Users have problems entering the file name only, they tend to delete ...