Jump to content

ShellExecute - files with *


TomF
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

37 minutes ago, TomF said:

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

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
Link to comment
Share on other sites

57 minutes ago, TomF said:

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

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."

Link to comment
Share on other sites

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

11 hours ago, TomF said:

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

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

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
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
 Share

  • Recently Browsing   0 members

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