Sign in to follow this  
Followers 0
simpleraison

Cycling through all files in a folder for processing?

6 posts in this topic

I just wondered guys if there any code which will help me cycle through when selecting files from a location. For example the third party application requires a file input and i want it to process each file in a perticular folder before closing the applications. So the first time round of processing it could select 'test1' and then the second time around it would be 'test2' etc. It would be better if it could put them in a archive folder before selecting the next one and then when none are left it could finish the process!

Thanks guys.

Share this post


Link to post
Share on other sites



Hello simpleraison,

Look at _FileListToArray() to populate a list of the files you wish to use. And then create a loop and use control functions such as ControlSend() to enter them into the input box.

Hope this helps.

Realm


My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry.  

Share this post


Link to post
Share on other sites

Hello simpleraison,

Look at _FileListToArray() to populate a list of the files you wish to use. And then create a loop and use control functions such as ControlSend() to enter them into the input box.

Hope this helps.

Realm

Dude do you have a structure for the loop you can show me please? Sorry i am new to AutoIT and still learning! Would the loop be similar to a while loop?

Share this post


Link to post
Share on other sites

Hello simpleraison,

I know you just want to jump right into it, but this is one of those things in life that pay off more by doing the studying first. It will save you time, and us as well. Spend some time reading the 'Help File' and taking part in some tutorials. There are many tutorials on You Tube along with a Tutorial built in AutoIt in Example section of the Forums called: '

This Forum was designed to help fellow coders that encounter problems with their code. Asking for someone to write your code, will not get any good responses.

Once you have tried writing your own script, and your still having problems with it, Then create a post explaining in detail what your trying to achieve with your script, what errors/problems your having, and include your script in [autoit ] or [code ] tags, or at least an example of it. You will find that members will be more motivated to help those that show they are attempting to learn the language.

Realm

PS. Try reading up on these loop functions and find what suits your needs best:

While...WEnd.

Do...Until

For...To...Step...Next


My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry.  

Share this post


Link to post
Share on other sites

Hello simpleraison,

I know you just want to jump right into it, but this is one of those things in life that pay off more by doing the studying first. It will save you time, and us as well. Spend some time reading the 'Help File' and taking part in some tutorials. There are many tutorials on You Tube along with a Tutorial built in AutoIt in Example section of the Forums called: '

This Forum was designed to help fellow coders that encounter problems with their code. Asking for someone to write your code, will not get any good responses.

Once you have tried writing your own script, and your still having problems with it, Then create a post explaining in detail what your trying to achieve with your script, what errors/problems your having, and include your script in [autoit ] or [code ] tags, or at least an example of it. You will find that members will be more motivated to help those that show they are attempting to learn the language.

Realm

PS. Try reading up on these loop functions and find what suits your needs best:

While...WEnd.

Do...Until

For...To...Step...Next

Yeah sorry dude! Ok well just to set me off on my file selection adventure, just suggest to me atleast which looping system will suit this process the best. And i think i should be able to go from that!:-)

Share this post


Link to post
Share on other sites

I'm not sure this is what you wanted, but here is an example:

Opt('WinTitleMatchMode', 4)

#include <File.au3>
#include <Array.au3>

Local $Title = 'Open All Text/Ini Files in a Directory with Notepad'
Local $Message = 'This Script will allow you to select a Text/Ini file'
$Message &= ', open that file file with notepad, and then open the other Text/Ini files in that folder'
MsgBox(0, $Title, $Message)

Local $File = FileOpenDialog("Select a Text or INI file", @ScriptDir, "Text Files (*.txt)|Ini Files (*.ini)", 1)
If @error Then Exit
Run('notepad.exe "' & $File & '"')
Sleep(500)
$Array = _FileListToArray(@WorkingDir, '*', 1)
If Not IsArray($Array) Then Exit MsgBox(0, 'Error', 'No Files found in ' & @WorkingDir)
For $i = $Array[0] To 1 Step -1
    Switch StringRegExpReplace($Array[$i], '^.+\.', '')
        Case 'txt'
            ContinueLoop
        Case 'ini'
            ContinueLoop
        Case Else
            _ArrayDelete($Array, $i)
    EndSwitch
Next
$Array[0] = UBound($Array) - 1
_ArrayDisplay($Array, 'Text Documents in ' & @WorkingDir)
WinActivate('[REGEXPTITLE:Text Documents in ; CLASS:AutoIt v3 GUI]')
For $i = 1 To $Array[0]
    If Not StringInStr($File, $Array[$i]) Then
        Run('notepad.exe "' & @WorkingDir & '\' & $Array[$i] & '"')
        Sleep(500)
    EndIf
Next

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