Hi, so I have a list of files in a folder that I need to go through and execute one by one. I think I have everything else figured out.
It can not simply switch to the folder and press the down key once. Occasionally after executing one of the items on the list, the list will change. So I was hoping for a way that it could retrieve the list of files within the folder, then go down the list, and stop when the list ends.
How would I go about doing that?
Thanks
Noob question - going down a list
Moderators: Dorian (MJT support), JRL
- CyberCitizen
- Automation Wizard
- Posts: 721
- Joined: Sun Jun 20, 2004 7:06 am
- Location: Adelaide, South Australia
I would do something like this, however it depends on what your wanting to execute. If your wanting just exe's (programs) change *.* to *.exe
If its files you might need to replace the RunProgram with execute file.
Hope this helps.
Had to post script to pastebin as it wasn't being formatted correctly on the forum even with the code tags.
PasteBin Link To Script
If its files you might need to replace the RunProgram with execute file.
Hope this helps.
Had to post script to pastebin as it wasn't being formatted correctly on the forum even with the code tags.
PasteBin Link To Script
FIREFIGHTER
-
- Macro Veteran
- Posts: 267
- Joined: Mon Sep 27, 2010 8:57 pm
- Location: Seattle, WA
The GetFileList Help topic has a good sample to use.
When you mention the list may change as you are running this script, that increases the complexity quite a bit. That indicates you will need to do something like this:
When you mention the list may change as you are running this script, that increases the complexity quite a bit. That indicates you will need to do something like this:
Code: Select all
Create file list (GetFileList)
Separate into array
Get FileListCount
Create an AlreadyRunList (blank to start with)
Set counter = 0
Loop until counter=FileListCount
Let>counter=counter+1
Read item(counter) on file list
Check AlreadyRunList to see if file has been run
If file has not been run
Run the file
Add to file 'AlreadyRunList'
Recreate the file list
Separate into array
Get FileListCount
Let>Counter=0 (When the list is recreated you start at the top again)
Endif
Endloop
Thanks guys, much appreciated. Your example makes sense, Jerry, but where is the list actually created? Is this something I can actually see? Is it put into the 'watch list' tab?
This was in the help topic -
GetFileList>C:\Documents and Settings\vanderwey\Desktop\xFund 12-31-12,strFileList,;
Separate>files,;,file_names
MessageModal>Num Files: %file_names_count%
Let>k=0
Repeat>k
Let>k=k+1
Message>file_names_%k%
Until>k,file_names_count
I'm unsure of what the 'k' stuff is doing. Is K the number of the file on the list?
This was in the help topic -
GetFileList>C:\Documents and Settings\vanderwey\Desktop\xFund 12-31-12,strFileList,;
Separate>files,;,file_names
MessageModal>Num Files: %file_names_count%
Let>k=0
Repeat>k
Let>k=k+1
Message>file_names_%k%
Until>k,file_names_count
I'm unsure of what the 'k' stuff is doing. Is K the number of the file on the list?
-
- Macro Veteran
- Posts: 267
- Joined: Mon Sep 27, 2010 8:57 pm
- Location: Seattle, WA
The list is the array of file_names.
The list of file names will show in the Watch List.
The sample you copied goes through the list and shows the names of the files.
For your script, you would just change the "Message" line to
Run>file_names_%k%
'k' is the counter that starts at 0 and goes up to file_names_count.
(by default, arrays start at 0)
The percent sign is how you can combine a variable name and an indicator.
file_names_0 is the same as file_names_%k% when k=0
The loop keeps you from having to repeat a line like this
Message>file_names_0
Message>file_names_1
Message>file_names_2
Message>file_names_3
etc.
The list of file names will show in the Watch List.
The sample you copied goes through the list and shows the names of the files.
For your script, you would just change the "Message" line to
Run>file_names_%k%
'k' is the counter that starts at 0 and goes up to file_names_count.
(by default, arrays start at 0)
The percent sign is how you can combine a variable name and an indicator.
file_names_0 is the same as file_names_%k% when k=0
The loop keeps you from having to repeat a line like this
Message>file_names_0
Message>file_names_1
Message>file_names_2
Message>file_names_3
etc.
-
- Macro Veteran
- Posts: 267
- Joined: Mon Sep 27, 2010 8:57 pm
- Location: Seattle, WA