Jump to content

Open a txt file with wild card


Recommended Posts

I'm using this

Run("notepad.exe "&@Scriptdir&"\*.txt",@WindowsDir,)

To open a txt file that the file name will change from computer to computer but it will end with .txt . so how would I open the only txt file that will be in the main folder ?

Right now it gives me an error that it can't find the file .

I know I'm a pest .. lol

I should add a bat file is making the txt file and getting the name from the computer . so if it was johns computer it would be john.txt :D

Edited by bobheart
Link to comment
Share on other sites

Untested code, but should point you to the right functions in the help file. Also see FAQ #7 & 9 in the help file for issues about quotation marks.

$searchHandle = FileFindFirstFile( @Scriptdir & "\*.txt" )
If $searchHandle = -1 Then
   MsgBox(4096,"Error","File not found...quitting.)
   Exit
EndIf
$filename = FileFindNextFile($searchHandle)

Run("notepad.exe " & """" & $filename & """",@WindowsDir)

Edit: Neeed to put a space after notepad.exe

Edited by CyberSlug
Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

Whats a closing quote ?

---------------------------

AutoIt Error

---------------------------

Line 32 (File "C:\Documents and Settings\Candles\My Documents\My Downloads\history test\Text16.au3"):

MsgBox(4096,"Error","File not found...quitting")

MsgBox(4096,"Error",^ ERROR

Error: String missing closing quote.

---------------------------

never mind got that

MsgBox(4096,"Error","File not found...quitting")

still not finding the file ?

Edited by bobheart
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...