ioliver Posted December 8, 2005 Posted December 8, 2005 Here's my code: expandcollapse popup$output = FileOpen("C:\SearchIMF-Output.txt", 2); Opens for writing $dir = InputBox("Search IMF for @microsoft.com", "Full Path to Directory:") FileChangeDir($dir) DirCreate($dir & "\xp") $search = FileFindFirstFile("*.EML") ; Check if the search was successful If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf While 1 $file = FileFindNextFile($search) If @error Then ExitLoop ; MsgBox(4096, "File:", $file); Uncomment to test script $EML = FileOpen($file, 0) ; Check if file opened for reading OK If $EML = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ; Read in lines of text until the EOF is reached, or until "x-sender:" is found While 1 $line = FileReadLine($EML) If @error = -1 Then ExitLoop ; MsgBox(0, "Line read:", $line); Uncomment to test script If StringInStr($line, "x-sender:") <> 0 Then $x = 1 If StringInStr($line, "@microsoft.com") <> 0 Then ; MsgBox(0, "Search IMF.au3 found an email from Microsoft", $file); Uncomment to test script FileWriteLine($output, $file) FileMove($file, $dir & "\xp\" & $file) EndIf EndIf Wend FileClose($EML) WEnd FileClose($output) I know that the script is working, partly, but it does not move the file to the XP directory that I created. Any ideas? Thanks for your help, Ian "Blessed be the name of the Lord" - Job 1:21Check out Search IMF
seandisanti Posted December 8, 2005 Posted December 8, 2005 I know that the script is working, partly, but it does not move the file to the XP directory that I created. Any ideas?Thanks for your help,Ianyou can't move a file that's still open, but your FileClose isn't until after the move
ioliver Posted December 8, 2005 Author Posted December 8, 2005 you can't move a file that's still open, but your FileClose isn't until after the moveThanks cameronsdad, I thought that might be the problem. But, if I do a file close there will it effect my FileFindNextFile() ?Thanks,Ian "Blessed be the name of the Lord" - Job 1:21Check out Search IMF
seandisanti Posted December 8, 2005 Posted December 8, 2005 Thanks cameronsdad, I thought that might be the problem. But, if I do a file close there will it effect my FileFindNextFile() ?Thanks,Ianno, because you'll be closing the $file instead of the $search
poisonkiller Posted December 8, 2005 Posted December 8, 2005 I didnt wanted to make a new topic, so i post my problem here: $folder = FileSelectFolder("Select folder where is mp3 files...", @ScriptDir) $search = FileFindFirstFile($folder &"\*.*") While 1 $file = FileFindNextFile($search) If @error Then Exit If StringRight($file, 3) = "mp3" Then $name = $folder &"\" &$file ; Instantiate a COM instance with your new dll $oId3 = ObjCreate("CDDBControl.CddbID3Tag") ; Load the tags from your specified file - they are now available in the form $oId3.TagName $oId3.LoadFromFile ($name, True); True means open for read-only ; Copy tag information into variables $sTitle = $oId3.Title $sLeadArtist = $oId3.LeadArtist FileMove($name, $folder &"\" &$sLeadArtist &" - " &$sTitle &".mp3") EndIf WEndThis needs dll what you can download from here: http://www.helpy.com.ar/cen-dll/c.htmThis code should find mp3 file and rename it to its real name... But FileMove() is not working!PS: Many thanks to DaleHohm for this .dll and code
GaryFrost Posted December 8, 2005 Posted December 8, 2005 I didnt wanted to make a new topic, so i post my problem here: $folder = FileSelectFolder("Select folder where is mp3 files...", @ScriptDir) $search = FileFindFirstFile($folder &"\*.*") While 1 $file = FileFindNextFile($search) If @error Then Exit If StringRight($file, 3) = "mp3" Then $name = $folder &"\" &$file ; Instantiate a COM instance with your new dll $oId3 = ObjCreate("CDDBControl.CddbID3Tag") ; Load the tags from your specified file - they are now available in the form $oId3.TagName $oId3.LoadFromFile ($name, True); True means open for read-only ; Copy tag information into variables $sTitle = $oId3.Title $sLeadArtist = $oId3.LeadArtist FileMove($name, $folder &"\" &$sLeadArtist &" - " &$sTitle &".mp3") EndIf WEnd This needs dll what you can download from here: http://www.helpy.com.ar/cen-dll/c.htm This code should find mp3 file and rename it to its real name... But FileMove() is not working! PS: Many thanks to DaleHohm for this .dll and code Looks like same type of problem $oId3.LoadFromFile ($name, True); True means open for read-only SciTE for AutoItDirections for Submitting Standard UDFs  Don't argue with an idiot; people watching may not be able to tell the difference. Â
ioliver Posted December 8, 2005 Author Posted December 8, 2005 no, because you'll be closing the $file instead of the $search camersonsdad, Here's the updated part of my code, but it errors out after it copies the first file... ; Read in lines of text until the EOF is reached, or until "x-sender:" is found While 1 $line = FileReadLine($EML) If @error = -1 Then ExitLoop ; MsgBox(0, "Line read:", $line); Uncomment to test script If StringInStr($line, "x-sender:") <> 0 Then $x = 1 If StringInStr($line, "@xpsystems.com") <> 0 Then ; MsgBox(0, "Search IMF.au3 found an email from XP Systems", $file); Uncomment to test script FileWriteLine($output, $file) FileClose($EML) FileMove($file, $dir & "\xp\" & $file) $EML = FileOpen($file) EndIf EndIf Wend FileClose($EML) WEnd FileClose($output) Thanks for the help, Ian "Blessed be the name of the Lord" - Job 1:21Check out Search IMF
poisonkiller Posted December 8, 2005 Posted December 8, 2005 Okey sorry about my bad english... I cant speak english very well... I want get ID3 tags from .mp3 file, and rename something like "01 - somesong" with FileMove() to "Artist from .mp3 file" &" - " &"Song name from .mp3 file". Thanks!
GaryFrost Posted December 8, 2005 Posted December 8, 2005 @ioliver, sorry about your thread being somewhat hijacked@poisonkiller, don't the the proper calls to the dll your using, but loadfile opens the file, is there a closefile or something like it? if so you may need to do that 1st then rename. SciTE for AutoItDirections for Submitting Standard UDFs  Don't argue with an idiot; people watching may not be able to tell the difference. Â
ioliver Posted December 8, 2005 Author Posted December 8, 2005 @ioliver, sorry about your thread being somewhat hijacked@poisonkiller, don't the the proper calls to the dll your using, but loadfile opens the file, is there a closefile or something like it? if so you may need to do that 1st then rename.@gafost, no problem. Got any ideas about my problem?Thanks,Ian "Blessed be the name of the Lord" - Job 1:21Check out Search IMF
ioliver Posted December 8, 2005 Author Posted December 8, 2005 Here's the new thing I tired: ; Read in lines of text until the EOF is reached, or until "x-sender:" is found While 1 $line = FileReadLine($EML) If @error = -1 Then ExitLoop ; MsgBox(0, "Line read:", $line); Uncomment to test script If StringInStr($line, "x-sender:") <> 0 Then If StringInStr($line, "@xpsystems.com") <> 0 Then ; MsgBox(0, "Search IMF.au3 found an email from XP Systems", $file); Uncomment to test script FileWriteLine($output, $file) FileClose($EML) FileMove($file, $dir & "\xp\" & $file) $x = 1 EndIf EndIf Wend If $x <> 1 Then FileClose($EML) EndIf WEnd FileClose($output) Here's the error I got: Search IMF.au3 (29) : ==> Invalid file handle used.: $line = FileReadLine($EML) Thanks, Ian "Blessed be the name of the Lord" - Job 1:21Check out Search IMF
GaryFrost Posted December 8, 2005 Posted December 8, 2005 Here's the new thing I tired: ; Read in lines of text until the EOF is reached, or until "x-sender:" is found While 1 $line = FileReadLine($EML) If @error = -1 Then ExitLoop ; MsgBox(0, "Line read:", $line); Uncomment to test script If StringInStr($line, "x-sender:") <> 0 Then If StringInStr($line, "@xpsystems.com") <> 0 Then ; MsgBox(0, "Search IMF.au3 found an email from XP Systems", $file); Uncomment to test script FileWriteLine($output, $file) FileClose($EML) FileMove($file, $dir & "\xp\" & $file) $x = 1 EndIf EndIf Wend If $x <> 1 Then FileClose($EML) EndIf WEnd FileClose($output) Here's the error I got: Thanks, Ian move your if $x <> 1 above the Wend above it SciTE for AutoItDirections for Submitting Standard UDFs  Don't argue with an idiot; people watching may not be able to tell the difference. Â
poisonkiller Posted December 8, 2005 Posted December 8, 2005 @ioliver, sorry about your thread being somewhat hijacked@poisonkiller, don't the the proper calls to the dll your using, but loadfile opens the file, is there a closefile or something like it? if so you may need to do that 1st then rename.I dont know... I dont to nothing about .dll-s and reading .dll-s...
seandisanti Posted December 8, 2005 Posted December 8, 2005 (edited) ; Read in lines of text until the EOF is reached, or until "x-sender:" is found While 1 $line = FileReadLine($EML) If @error = -1 Then ExitLoop ; MsgBox(0, "Line read:", $line); Uncomment to test script If StringInStr($line, "x-sender:") <> 0 Then $x = 1 If StringInStr($line, "@xpsystems.com") <> 0 Then ; MsgBox(0, "Search IMF.au3 found an email from XP Systems", $file); Uncomment to test script FileWriteLine($output, $file) FileClose($EML)FileMove($file, $dir & "\xp\" & $file) $EML = FileOpen($file) EndIf EndIf Wend FileClose($EML) WEndFileClose($output)the highlighted section is the issue. the $file still points at the file's original location, where it no longer exists after you move it. the second highlighted file tries to open the file that no longer exists. On the brights side it looks like you don't do anything with it after opening it again, so i'd just remove that line, and the second FileClose($EML) too.***edit*** fixed the coloring of the lines i was talking about Edited December 8, 2005 by cameronsdad
ioliver Posted December 8, 2005 Author Posted December 8, 2005 What about using an ExitLoop(), like this: ; Read in lines of text until the EOF is reached, or until "x-sender:" is found While 1 $line = FileReadLine($EML) If @error = -1 Then ExitLoop ; MsgBox(0, "Line read:", $line); Uncomment to test script If StringInStr($line, "x-sender:") <> 0 Then If StringInStr($line, "@xpsystems.com") <> 0 Then ; MsgBox(0, "Search IMF.au3 found an email from XP Systems", $file); Uncomment to test script FileWriteLine($output, $file) FileClose($EML) FileMove($file, $dir & "\xp\" & $file) ;$x = 1 ExitLoop(3) EndIf EndIf Wend ;If $x <> 1 Then FileClose($EML) ;EndIf WEnd FileClose($output) But I get this error: Search IMF.au3 (39) : ==> "ExitLoop/ContinueLoop" statements only valid from inside a For/Do/While loop.: ExitLoop(3) Thanks, Ian "Blessed be the name of the Lord" - Job 1:21Check out Search IMF
seandisanti Posted December 8, 2005 Posted December 8, 2005 But I get this error:Thanks,Iancould you re-post a full listing of your script?
ioliver Posted December 8, 2005 Author Posted December 8, 2005 could you re-post a full listing of your script? Sure. Thanks for your help with this. I've tried a couple of different things, but here's what I'm working with now: expandcollapse popup$output = FileOpen("C:\SearchIMF-Output.txt", 2); Opens for writing $dir = InputBox("Search IMF for @ms.com", "Full Path to Directory:") FileChangeDir($dir) DirCreate($dir & "\xp") $search = FileFindFirstFile("*.EML") ; Check if the search was successful If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf While 1 ;$x = 0 $file = FileFindNextFile($search) If @error Then ExitLoop ; MsgBox(4096, "File:", $file); Uncomment to test script $EML = FileOpen($file, 0) ; Check if file opened for reading OK If $EML = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ; Read in lines of text until the EOF is reached, or until "x-sender:" is found While 1 $line = FileReadLine($EML) If @error = -1 Then ExitLoop ; MsgBox(0, "Line read:", $line); Uncomment to test script If StringInStr($line, "x-sender:") <> 0 Then If StringInStr($line, "@ms.com") <> 0 Then ; MsgBox(0, "Search IMF.au3 found an email from ms", $file); Uncomment to test script FileWriteLine($output, $file) FileClose($EML) FileMove($file, $dir & "\xp\" & $file) $EML = FileOpen($dir & "\xp\" & $file) ;$x = 1 EndIf EndIf ;If $x = 1 Then ExitLoop Wend FileClose($EML) WEnd FileClose($output) "Blessed be the name of the Lord" - Job 1:21Check out Search IMF
seandisanti Posted December 8, 2005 Posted December 8, 2005 Sure. Thanks for your help with this. I've tried a couple of different things, but here's what I'm working with now: expandcollapse popup$output = FileOpen("C:\SearchIMF-Output.txt", 2); Opens for writing $dir = InputBox("Search IMF for @ms.com", "Full Path to Directory:") FileChangeDir($dir) DirCreate($dir & "\xp") $search = FileFindFirstFile("*.EML") ; Check if the search was successful If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf While 1 ;$x = 0 $file = FileFindNextFile($search) If @error Then ExitLoop ; MsgBox(4096, "File:", $file); Uncomment to test script $EML = FileOpen($file, 0) ; Check if file opened for reading OK If $EML = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ; Read in lines of text until the EOF is reached, or until "x-sender:" is found While 1 $line = FileReadLine($EML) If @error = -1 Then ExitLoop ; MsgBox(0, "Line read:", $line); Uncomment to test script If StringInStr($line, "x-sender:") <> 0 Then If StringInStr($line, "@ms.com") <> 0 Then ; MsgBox(0, "Search IMF.au3 found an email from ms", $file); Uncomment to test script FileWriteLine($output, $file) FileClose($EML) FileMove($file, $dir & "\xp\" & $file) $EML = FileOpen($dir & "\xp\" & $file) ;$x = 1 EndIf EndIf ;If $x = 1 Then ExitLoop Wend FileClose($EML) WEnd FileClose($output)i'm still going through it, but one thing that jumps out at me is that you don't have an exit condition for your inner while loop.
seandisanti Posted December 8, 2005 Posted December 8, 2005 i'm still going through it, but one thing that jumps out at me is that you don't have an exit condition for your inner while loop.try this: $output = FileOpen("C:\SearchIMF-Output.txt", 2); Opens for writing $dir = InputBox("Search IMF for @ms.com", "Full Path to Directory:") FileChangeDir($dir) DirCreate($dir & "\xp") $search = FileFindFirstFile("*.EML") ; Check if the search was successful If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf While 1 ;$x = 0 $file = FileFindNextFile($search) If @error Then ExitLoop ; MsgBox(4096, "File:", $file); Uncomment to test script $EML = FileOpen($file, 0) ; Check if file opened for reading OK If $EML = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf $fc = FileRead($EML, FileGetSize($EML)) If StringInStr($fc, "@ms.com") Then FileWriteLine($ouput, $file) FileClose($EML) FileMove($file, $dir & "\xp\" & $file) ;### Tidy Error: Level error -> WEnd is closing previous if WEnd ;### Tidy Error: Level error -> EndIf is closing previous While EndIf FileClose($output)
ioliver Posted December 8, 2005 Author Posted December 8, 2005 i'm still going through it, but one thing that jumps out at me is that you don't have an exit condition for your inner while loop.I'd like for the 2nd to innermost loop to not run if it finds the word 'x-sender', but I didn't know how to code that. Is that what you mean by exit condition?Thanks again,Ian "Blessed be the name of the Lord" - Job 1:21Check out Search IMF
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now