Opening each file in a folder?

Hey There!

Soooo, I want to make our windows application open a file in a windows folder, run a test script, close that file, open the next file in that same folder. Repeat

Eventually opening each file in the test folder.

Make sense? I get the Repeat command but how do you point to a folder as a source and then say “open each file in order”?

Thanks for any help!

Have you looked at the files function? It returns a list of files contained in the folder you specify. You can iterate through that list.

Thought this may help too…

params  folder
repeat with each item file in the files of folder
	mangle file  
end repeat

Untested, but pray tell it works.

The files() function is exactly what you want to use… if you’re working with files on the local Mac where Eggplant is running. It can also access files on remote computers if those file systems are mounted locally across the network.

On the other hand, to get your application on the SUT to open different files, you’ll have to find a way to cycle through them in the same way a user would. My guess is that the simplest way to do this may be to open the folder in Windows Explorer, select the first file and open it. Then when you’re done processing the file, return to Windows Explorer and select the next file by typing a down-arrow and open it, etc. I don’t have access to a Windows machine right now to see exactly how this might work, but you may want to try something along those lines.

Very nice suggestions all! I think the best for our situation is to cycle through the ones on the SUT using the down arrow. Since these are Windows files, windows executable…etc… thanks!

Oops! I answered the wrong question.

I’m curious now. You can use dnarrow, but then how do you determine you’re at the end of the list?

I can imagine a ENDKEY, theend=CaptureScreen, HOMEKEY, dnarrow until CaptureScreen = “theend”.
But that seems pretty wacky.

If these are executables you’re running, then you could make your own .exe that pops up a window “End of list dummy” and then look for that. You would have to name this something to put it at the end, like ___endoflist.exe. That seems even more odd.

There must be a better way!

( And if you’re dnarrow, ENTERKEYing the whole way how do you keep from accidentally navigating into a sub-directory? )

Files generally have unique file paths that describe their location on a heirarchical file system, and thus in any given folder you can not have duplicate file names with the exact same name (backups often have ~ after them, or hidden files have “.” in front, at least in the world of linux/unix, and .bck in the windows world). This makes it easy to verify that you are at the end, since the only time you will have a duplicate selection on the remote host in a file system browser (in details view), is at the beginning or end of a loop using the up or down arrow keys.

I hope this helps.