Sign in to follow this  
Followers 0
hakan

I NEED HELP

5 posts in this topic

Hi..It is my first Question here..i hope someone can help me about it..

I have to make a short program with Autoit that reads some files according to the given keywords in these files..

example: I have a text file (.txt) and there are songs in it..

FILE "test.mp3" MP3

TRACK 783 AUDIO

TITLE "A l'enterrement de Sidney Bechet"

PERFORMER "Patricia Kaas"

INDEX 01 00:00:00

TRACK 784 AUDIO

TITLE "Kennedy Rose"

PERFORMER "Patricia Kaas"

INDEX 01 00:58:00

i want this program to read only the name of the songs with the help of keyword "title" and at the same time opens or create a new text file which contains the name of the songs.

Share this post


Link to post
Share on other sites



#include <File.au3>
#include <String.au3>

$filepath = "path"
$filename = "name"
$newpath = "new file's path"
$newfile = _FileCreate($newpath)
$newname = "new file's name"
$newfile = FileOpen($newname, 1)

$lines = _FileCountLines($filepath)

If $lines > 0 Then
    $file = FileOpen($filename, 0)
    If $file = -1 Then
        MsgBox(0, "Error", "Unable to open file.")
        Exit
    EndIf
EndIf

For $i = 0 To $lines
    $text = FileReadLine($filename, $i)
    sleep(10)
    If StringInStr($text, "TITLE") Then
        $temp = StringInStr($text, '"')
        $temp = StringMid($text, $temp)
        $tracktitle = StringTrimLeft($temp, 1)
        $tracktitle = StringTrimRight($tracktitle, 1)
        FileWriteLine($newfile, $tracktitle)
    EndIf   
Next

Something like that....(untested).


IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Hi..

thank you for your reply.

However i have 3 .txt files..and every file contains song names inside..

i wanted the program to find these files first and then according to the keyword "title" shows all song names in a txt file. I know it seems to be easy but i have no experience with this program ( it is my homework)

but however your solution gives the file but there is nothing in it.

i tried to add the following to your solution to let the proram find the files first and than search the song names and give them out with a new text file...

is ist true?

$search = FileFindFirstFile("*.txt")

Edited by hakan

Share this post


Link to post
Share on other sites

Yes, if you don't know the path of the file, you can use FileFindFirstFile() and FileFindNextFile(). To make it search for more than one file, you can have it look for all .txt files and run it's search for "TITLE" in each one.


IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]

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  
Followers 0