Jump to content

stringregex please explain in dumb[Solved] thanks folks


Recommended Posts

I cannot figure out how this works ! the help file is very hard to understand on this topic below I have a less then stellar example. its suspose to get all the audio files from this folder and move them to another folder.

HotKeySet('{esc}','esc')

Func esc()
    exit 0
EndFunc


While 1 
$media = '(wma|mp3|wav)'
$good = StringRegExp(@ScriptDir & "\*.*",@ScriptDir & "\*."&$media,0)
if $good = 1 then
FileMove(@ScriptDir & "\*."&$media, @ScriptDir & "\Music\", 9)
else
sleep(100)
endif
WEnd
Edited by lordicast
[Cheeky]Comment[/Cheeky]
Link to comment
Share on other sites

Thanks to all the responded! very good advise and will follow the filefindfirstfile approach.

from help.

$search = FileFindFirstFile("*.*")  ;<--- where do i add my extenstions for the files? ie; (mp3,wma,wav) that are exceptable?


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)
WEnd


FileClose($search)
[Cheeky]Comment[/Cheeky]
Link to comment
Share on other sites

$search = FileFindFirstFile("*.*")  ;<--- where do i add my extenstions for the files? ie; (mp3,wma,wav) that are exceptable?
do three searches would be a simple method...

Dim $Ext[3] = ["mp3", "wma", "wav"]

For $i = 0 to ubound ($ext)
While Not @Error
;Search for File "*." & $Ext[$i]
Wend
Next

bound to have errors, just typed it out as an example.

MDiesel

edit: wow.... got practically exactly the same as rudi, but I got there first. ^_^

Edited by mdiesel
Link to comment
Share on other sites

Thanks everyone. FYI if anyone wants to know

HotKeySet('{esc}','esc')

Func esc()
    exit 0
EndFunc

while 1
    _Move()
WEnd

;===aMove
func _Move()
dim $MyExt[4]=["wav","mp3","wma","wmv"]

for $i In $MyExt
    $search = FileFindFirstFile("*."&$i)  
While 1
    $file = FileFindNextFile($search) 
    If @error Then ExitLoop
    TrayTip("Found File:", "Moving file "&$file,10)
    FileMove(@ScriptDir & "\"&$file, @ScriptDir & "\Music\", 9)
WEnd
FileClose($search)
next
EndFunc
[Cheeky]Comment[/Cheeky]
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...