Jump to content

Recommended Posts

Posted

Hallo,
I have problem with run files with asterix -  in this forum I did not find some result. I need to run some PDF files - their names will changed I will not know them.

This is OK: ShellExecute (@ScriptDir & "\Dir-1\file-1.pdf")
but this is bad: ShellExecute (@ScriptDir & "\Dir-1\*.pdf").

Is there any way to run files with asterix?

Thanks for your advice.

Posted (edited)

Hey,

Unless there would be a better way, I would approach this like:

Use "_FileListToArray" or "_FileListToArrayRec" functions according to folder structure, which you can use wildcards.

https://www.autoitscript.com/autoit3/docs/libfunctions/_FileListToArray.htm

https://www.autoitscript.com/autoit3/docs/libfunctions/_FileListToArrayRec.htm

#include <File.au3>
#include <FileConstants.au3>
#include <Array.au3>

; Non-recursive
Local $aFileList = _FileListToArray(@ScriptDir & "\Dir-1\","*.pdf",$FLTA_FILES)

if $aFileList = "" then exit ; or some error handling

For $i = 1 to $aFileList[0]
    ShellExecute(@ScriptDir & "\Dir-1\" & $aFileList[$i])
Next

; Recursive
Local $aFileList = _FileListToArrayRec(@ScriptDir & "\Dir-1\","*.pdf",$FLTAR_FILES)

if $aFileList = "" then exit ; or some error handling

For $i = 1 to $aFileList[0]
    ShellExecute(@ScriptDir & "\Dir-1\" & $aFileList[$i])
Next

 

Edited by GokAy
Corrected typo in ShellExecute
Posted

Hallo GojAy,

thanks for your quickl reply.  But
 

Local $aFileList = _FileListToArray(@ScriptDir & "\Dir-1\","*.pdf",$FLTA_FILES)

if $aFileList = "" then exit ; or some error handling

For $i = 1 to $aFileList[0]
    SheelExecute(@ScriptDir & "\Dir-1\" & $aFileList[$i])
Next

- unfortunately - it will not allow it:    D:\Autoit\Pokusy\2\Run-asterix-2.au3"(12,57) : error: SheelExecute(): undefined function.

Posted (edited)
  On 11/4/2020 at 7:55 PM, TomF said:

- unfortunately - it will not allow it:    D:\Autoit\Pokusy\2\Run-asterix-2.au3"(12,57) : error: SheelExecute(): undefined function.

Expand  

Look closely.  You don't see the problem?  I guess the error message saying "undefined function" wasn't a big enough hint.  :doh:

Edited by TheXman
Posted
  On 11/4/2020 at 7:55 PM, TomF said:

unfortunately - it will not allow it:    D:\Autoit\Pokusy\2\Run-asterix-2.au3"(12,57) : error: SheelExecute(): undefined function.

Expand  

Just in case you have mislaid your spectacles :lol:: ShellExecute() - SheelExecute()

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Posted

TheXman, Musashi - thank you very much. I'm sorry, English and programming are not my native languages... :doh::lol:

GokAy - great, now everything works 👍

 

Posted (edited)

When I was born my dad learned me the C++. 

  On 11/4/2020 at 9:50 PM, TomF said:

English and programming are not my native languages... :doh::lol:

Expand  

Just joking but I don't seen already someone with native programming language 😇

Edited by caramen

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

  Reveal hidden contents

 

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...