Hi,
Thank you for your enquiry.
The easiest way to achieve this would be to use an external batch file to create a list of all of the files in the specified directory. You could then use Opus' Storage actions to read the information from the generated list and display this information within a Listbox.
Please find attached an example publication and batch file which demonstrate this. Please ensure that both files are extracted to the same directory on your hard disk.
First, take a look at the contents of the batch file. To do this, simply right-click on the file and select
Edit from the menu which appears. This should open the batch file into Notepad and you should see the following:
Code:
@echo off
dir "%USERPROFILE%\My Documents\My Pictures\*.jpg" /b /s > list.txt
The
@echo off command tells the batch file to run silently so the end-user will not see the output of the 'dir' command on-screen.
As you are probably aware, the
dir command is used to list files in a directory.
%USERPROFILE% is an environment variable which equates to the Documents and Settings folder for the currently logged-on user.
*.jpg tells the batch file to list every file which has a JPG file extension.
The
/b switch tells the batch file to generate a list in 'bare' format and removes the usual volume and directory header information from the resulting list.
The
/s switch tells the batch file to include subdirectories in its search, so if you have a subfolder named 'Holiday Photos' in your My Pictures directory, images in this folder will be included in the final list.
Usually, the results of a 'dir' command are simply displayed on-screen within the command window, but the
> list.txt switch tells the batch file to 'print' the output to a file. As we have only specified the filename and not a path to the file, this 'list.txt' file will be created in the same location as the batch file.
Therefore,
%USERPROFILE%\My Documents\My Pictures\*.jpg /b /s > list.txt tells the batch file to generate a bare list of the paths to every JPG file in the current user's My Pictures folder (including subfolders) and store this list to a text file named 'list.txt'.
If you now examine my publication, you will see that I have added an
On Show trigger to the page, followed by these script actions (an explanation of each action has been added to each line of the script:
Code:
LaunchFile("list.bat") //launches the batch file in the publication directory
textObj = OpenFile("list.txt") //opens the text file which was generated by the batch actions
list = "" //initialises the 'list' variable to blank text
while (textObj.EndOfFile() == false) { //loops the following actions until the end of the text file is reached
currentfile = textObj.ReadLine() //reads the next line from the file and stores it to a variable named 'currentfile'
list = list + currentfile + "\n" //adds the currentfile to the existing list of files and appends a line return
wait() //pauses momentarily to allow the processor to catch up
} //ends the loop
Listbox.SetSelection(0,-1) //selects the entire contents of the Listbox object on the page
Listbox.ReplaceSelection(list) //inserts the list of files into the Listbox
I have created a Listbox object on the page (named 'Listbox') which displays the list of files and I have set this Listbox to store the text of any items selected to a new variable named 'image'.
Finally, I have added an Image object to the page and have set the filename of this Image object to the 'image' variable.
If you preview the publication, you should see a list of JPG files appear in the Listbox and clicking on one of these files should display the corresponding image within the Image object.
This should hopefully give you enough information to create your media player style publication, but please do not hesitate to contact me if you have any further queries.
Kind regards,