Loop through folder and save as Txt

prasadgov

Member
Local time
Today, 16:38
Joined
Oct 12, 2021
Messages
114
Hi,

I receive data in files with FTPRCV types dumped into my folder
I need to loop through the folder and save these files as txt files

I receive files as RR20240628060101, RR20240628060102.....
Also, if file types are 20240628060101.FTPRCV, 20240628060102.FTPRCV........then how would the code look like

My code is unfinished
Code:
Dim strfile as string
strfile = Dir("C:\dailyfolder\*RR2024*")
Do While Len(strfile) > 0
.........
How to save all these files as text file with the same names?
 
How to save all these files as text file with the same names?
What does that mean. You cannot same multiple files in the same folder with the same name. These files are already save in your folder. I assume you mean change the extension to .txt not convert to a text file from something else? Are you moving these files, renaming, copying, or what?
 
Just append .txt to the name, or replace ftprcv with txt?
Why do you need to change the extension?
 
The simplest solution is to use Scripting.FileSystemObject. When I can get near myPC I'll knock up some example code. Where do want to save the text files to? The same folder? Are the FTPRCV files the only ones in the folder?

You may well get other solutions before I can produce the promised code, however.
 
Just append .txt to the name, or replace ftprcv with txt?
Why do you need to change the extension?
I need to read these contents into a single field in my Access table after which I parse using Mid function.
I will be using either the transfertext or VBA code to get the data into Access.
Under current FTPRCV or RR, I am unable to or I am unaware how to.
I think replacing the file extension as .txt would be the way.
 
What does that mean. You cannot same multiple files in the same folder with the same name. These files are already save in your folder. I assume you mean change the extension to .txt not convert to a text file from something else? Are you moving these files, renaming, copying, or what?
Yes, I mean change the extension to .txt
 
The simplest solution is to use Scripting.FileSystemObject. When I can get near myPC I'll knock up some example code. Where do want to save the text files to? The same folder? Are the FTPRCV files the only ones in the folder?

You may well get other solutions before I can produce the promised code, however.
I need to read these contents into a single field in my Access table after which I parse using Mid function.
I need to rename them as .txt files either in the same folder or different.
I will be using either the transfertext or VBA code to get the data into Access.
I wonder if the text files can be saved without delimiters?
 
I need to read these contents into a single field in my Access table after which I parse using Mid function.
I will be using either the transfertext or VBA code to get the data into Access.
Under current FTPRCV or RR, I am unable to or I am unaware how to.
I think replacing the file extension as .txt would be the way.
TransferText doesn't care what extension a file has, as long as it is a text file. Just use files as supplied. Or use FSO as I recommended above and copy the contents directly into
 
I need to read these contents into a single field in my Access table after which I parse using Mid function.
I will be using either the transfertext or VBA code to get the data into Access.
Under current FTPRCV or RR, I am unable to or I am unaware how to.
I think replacing the file extension as .txt would be the way.
Well I have never used transfer text, but I cannot believe it would be bothered about the extension?
 
To analyze a string, you don't have to import it into a field in an Access table first. With a function like the one linked below, you can read the contents of any file, preferably a text file, into a string variable and then immediately start your analysis and processing.
The corresponding results can then be saved for a later point.

ReadFile
 
If you are only renaming a file,


The Name x As y statement should do what you want. As to the other issues, you have been given a good bit of advice so I won't add on.
 

Users who are viewing this thread

Back
Top Bottom