Jump to content
Sign in to follow this  

Multiple File Find & Open

Recommended Posts


Hi there

I have created a script that will show the file open dialog with a filter on the first 3 digits of the filename. I can get it to work to open one file, but when it comes to opening multiple files, I have created a further script as per below, but cannot seem to get it to work.

I'd appreciate a fresh pair of knowledgable eyes on this.

thanks, very much, Phil

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#Include <Array.au3>
$SC = InputBox("Open a PDF","Type the SC of the PDFs you want to see")
$filter = "PDFs (" & $SC & "*.pdf)"
$message = "Hold down Ctrl or Shift to choose multiple files."
$var = FileOpenDialog($message, "S:\Shared\EXCEL\PDF\", $filter, 1 + 4 )
If @error Then
MsgBox(4096,"","No File(s) chosen")
$var = StringReplace($var, "S:\Shared\EXCEL\PDF", "")
$var = StringReplace($var, "|", ",S:\Shared\EXCEL\PDF\")
$files = StringSplit($var,",")

$end = _ArrayMaxIndex($files)
$n = 1
while $n < $end
  $n = $n + 1

Share this post

Link to post
Share on other sites


_ArrayMaxIndex does not do what you think it does - it tells you the element with the highest value, not the number of elements. For that you use UBound. :doh:

But in fact StringSplit gives you the count in the [0] element so you can do this: :oops:

For $n= 2 To $files[0]
    MsgBox(4096, "", $files[$n)

You need to start at 2 becaus the [0][ element is the count and [1] will always be empty because you have a leading "," which you add. ;)

All clear? Please ask if not. :bye:


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:


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

To add to Melba23's comments, if you are going to use a while loop, you need to add one to either the $files[0] count element or Ubound($files) with your less than operator.


$n = 2

While $n < $files[0] + 1

MsgBox(4096, "", $files[$n])

$n = $n + 1


Edited by Reg2Post

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