Jump to content
Sign in to follow this  
DysFunction

AutoIT read all files in directory

Recommended Posts

DysFunction

Hey all,

I had a few questions, I'm new to Autoit and programming in general, about a week in, I've written a fully functional script or program, most of the information I needed was from the wiki/help file and the forums so that was awesome.

I'd like to read all files ending with *.txt in a directory and use regex to pull only certain data. for instance, the first column of numbers up to a comma.

For example

\(^[0-9]+\),

Making this group 1, excluding the comma.

Then sum all the returned values.

This would be trivial in bash and I know autoit supports regex, could someone point me in the right direction?

Also,

Another newbie question, if I have a DLL file, for example imagesearch which I've used extensively, is it possible to port this to another programming language and use the same DLL but process the returned data in a method thats specific to the language? Say for example C#.

Is there any books or tutorials etc that someone can recommend to get more 'up to speed' on these kind of things?

Thanks,

DysFunction

Share this post


Link to post
Share on other sites
Melba23

DysFunction,

Welcome to the AutoIt forum. :)

I'd like to read all files ending with *.txt in a directory

Then you need _FileListToArray. That gets you an array of filenames which you can loop through with For...Next, using FileRead to get the content of the files. You can extract the data you require in several ways: StringRegExp and StringSplit could both do what you want. :)

Could I gently point you to the Help file for more details? And you can easily search for other functions you might need within it. ;)

As to the DLL question, I leave the final word to others, but you should be able to call a DLL in any language. :)

M23


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
DysFunction

So _FileListToArray to add all the file names I need, with StringRegExp to only get .txt files

Then a For loop to go through and add all the values I need to an array.

Then another for Loop to go through all the items in the array to sum them.

That makes sense, is that correct, and a good way to approach it?

Share this post


Link to post
Share on other sites
Melba23

DysFunction,

You do not need a regex to select only the .txt files - the function has a filter that will do that for you, as the Help file tells you (I did suggest that you look in there for more details). You would use the regex to extract the data from each file as you looped through the returned array. ;)

Why not try to code something yourself to see what you can come up with - we tend to work on the "teach a man to fish, not give him a fish" principle here. You know where we are if you run into problems. :)

M23


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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  

×