Jump to content
Sign in to follow this  
lordicast

stringregex please explain in dumb[Solved] thanks folks

Recommended Posts

lordicast

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]

Share this post


Link to post
Share on other sites
exodius

You're not looking for StringRegExp (which is used to match strings based on regular expressions), you're looking for FileFindFirstFile/FileFindNextFile or _FileListToArray.

Edited by exodius

Share this post


Link to post
Share on other sites
Mat

you can only search strings with stringregexp.

use filefindfirstfile, wildcards are supported.

put it in a loop with filefindnextfile, thats all pretty well documented i think.

Edit: Why am I always second?

Edited by mdiesel

Share this post


Link to post
Share on other sites
Qousio

Even though Exodius answered your question, try looking at the "Tutorial - Regular Expression". Its very easy to follow.

Share this post


Link to post
Share on other sites
lordicast

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]

Share this post


Link to post
Share on other sites
Mat

$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

Share this post


Link to post
Share on other sites
rudi

Hi.

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

Regards, Rudi.


Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post


Link to post
Share on other sites
lordicast

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]

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  

×