Jump to content
Sign in to follow this  
PhilBall

Multiple File Find & Open

Recommended Posts

PhilBall

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 ****
#AutoIt3Wrapper_icon=C:\Users\phil.PAYCHECK\Desktop\PDF.ICO
#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")
Else
$var = StringReplace($var, "S:\Shared\EXCEL\PDF", "")
$var = StringReplace($var, "|", ",S:\Shared\EXCEL\PDF\")
$files = StringSplit($var,",")

EndIf
;_ArrayDisplay($files)
$end = _ArrayMaxIndex($files)
$n = 1
while $n < $end
  $n = $n + 1
;msgbox(4096,"",$files[$n])
  ShellExecute($files[$n])
WEnd

Share this post


Link to post
Share on other sites
Melba23

PhilBall,

_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)
    ;ShellExecute($files[$n])
Next

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:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

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
Reg2Post

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.

Example:

$n = 2

While $n < $files[0] + 1

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

$n = $n + 1

WEnd

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  

×