Sign in to follow this  
Followers 0
cleston

Read txt

6 posts in this topic

I'm very new at autoit (just did the basic tutorials) and not much of a programmer, so forgive the probably trivial/poorly stated question:

I wanted to open the most recent .txt in a folder full of other .txt documents and put its info in a variable so I can work with it withing autoit. I want to avoid explicitly opening the document and using clipboard (this is the only solution I could think of).

So, is there a function to read a txt directly? Any suggestions on reading the file by date and not by name?

Thanks in advance!

Share this post


Link to post
Share on other sites



You can use FileGetTime() to determine the most recent folder. See help file.

To read the entire contents to a variable use FileRead(). The first parameter can be an open file handle, but it doesn't have to be. You can just use the file path and read the whole file at once.

:x


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Thank you, PsaltyDS, that was very helpful, FileRead() was exactly what I was looking for.

As for FileGetTime(), I'm not sure how to use it. The thing is that it requires a filename or handle and my difficulty is precisely in getting one of the two. All that I know is the folder where the file is and that I want to open the most recent file. Did you have something in mind?

Perhaps this should be a windows functionality rather than an autoit function? I'm using windows 7, btw.

Share this post


Link to post
Share on other sites

Couple of functions you might want to look at are

FileFindFirstFile() and its related functions FileClose(), and FileFindNextFile(). and loop through the folder checking the dates with the suggested function.

You could also look at _FileListToArray() and loop through a resulting array.


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

Hum... I think that will work.

Thanks!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0