Jump to content

Recommended Posts

Posted

Ive got a script to look for sections in inifiles and change bits if needed -

How can i get the FileFindFirstFile, FileFindnextFile function to search sub folders. *.* only searches within the current folder.

Any Ideas?

Stretch

Posted

FileGetAttrib() call this on every file you get using findnextfile adn if FileGetAttrib() returns "D" for directory then make a recursive call to the find files function.

_____________________________________________________"some people live for the rules, I live for exceptions"Wallpaper Changer - Easily Change Your Windows Wallpaper

Posted

Have a look Here


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Posted

Search ("c:", "ini");replace with your search directory and file extension required

Func Search($current,$ext)

    Local $search = FileFindFirstFile($current & "\*.*")
    While 1
        Dim $file = FileFindNextFile($search)
        If @error Or StringLen($file) < 1 Then ExitLoop
        If Not StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "." Or $file <> "..") Then

            If StringInStr($current & "\" & $file, $ext) then 
                MsgBox (0, "Has the file extension " & $ext, $current & "\" & $file)
                ;this is where you do what you need to do
            Endif
        EndIf
        If StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "." Or $file <> "..") Then
            Search($current & "\" & $file, $ext)
            
        EndIf
    WEnd
    FileClose($search)

EndFunc

Posted

Search ("c:", "ini");replace with your search directory and file extension required

Func Search($current,$ext)

    Local $search = FileFindFirstFile($current & "\*.*")
    While 1
        Dim $file = FileFindNextFile($search)
        If @error Or StringLen($file) < 1 Then ExitLoop
        If Not StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "." Or $file <> "..") Then

            If StringInStr($current & "\" & $file, $ext) then 
                MsgBox (0, "Has the file extension " & $ext, $current & "\" & $file)
                ;this is where you do what you need to do
            Endif
        EndIf
        If StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "." Or $file <> "..") Then
            Search($current & "\" & $file, $ext)
            
        EndIf
    WEnd
    FileClose($search)

EndFunc
I seem to recall reading in one of the Beta version help files that "." and ".." will no longer be returned.

Regadless, a long time ago I started replacing

And ($file <> "." Or $file <> "..")

with

And StringRight($File,1) <> "."

If you are looking for folders only its

If StringInStr($File,".") = 0 Then MsgBox(4096,'TEST', $File & " is a folder")

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...