Jump to content
Sign in to follow this  
bobheart

Open a txt file with wild card

Recommended Posts

bobheart

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

Share this post


Link to post
Share on other sites
CyberSlug

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!

Share this post


Link to post
Share on other sites
bobheart

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

Share this post


Link to post
Share on other sites
bobheart

Ya I found it right after I posted that . lol but still can't find that damn txt file ..

Share this post


Link to post
Share on other sites
Valik

That's because Notepad doesn't accept wildcards for opening a file.

Share this post


Link to post
Share on other sites
bobheart

That's because Notepad doesn't accept wildcards for opening a file.

What will i can change the name to html ,doc ?

Share this post


Link to post
Share on other sites
bobheart

I take it this can't be done then ? If not all try something else .

Share this post


Link to post
Share on other sites
bobheart

Yes I saw it but did not understand it .

Share this post


Link to post
Share on other sites
bobheart

Never mind I got it to work .

Share this post


Link to post
Share on other sites
bobheart

Thank you larry that work fine ..

Sorry i don't know this stuff and I keep asking for help ..

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  

×