Jump to content

search files by attribute


TuMiM
 Share

Recommended Posts

I am trying to write something that will search through a folder and subfolder for all files with a specific attribute. I know how to do it for one file in a specific path but how do you do it for multiple files and also search through sub directories?

$input2 = GUICtrlRead($input1)
          $path1 = "\\server\storage\Core Folder" & "\" & $Input2
          $attrib = FileGetAttrib($path1 & "\" & $input2 & ".avi")
          If StringInStr($attrib, "O") Then
        MsgBox(4096, "Offline", "Files in folder " & $input2 & " are offline", 10)
               Endif
          Endif
Link to comment
Share on other sites

Is this any use? you'll need the beta version of AutoIT

Search ("D:\Kiosk");replace with your search directory



Func Search($current)

    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(FileGetAttrib($current & "\" & $file), "R") then MsgBox (0,$current & "\" & $file, "Has Attribut r")
            
        EndIf
        If StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "." Or $file <> "..") Then
            Search($current & "\" & $file)
            
        EndIf
    WEnd
    FileClose($search)

EndFunc
Edited by ChrisL
Link to comment
Share on other sites

That works, thanks. Is there any way to populate a list box or something like that with the results?

You need to creat a Gui with a listbox

$mylist=GUICtrlCreateList ("", 176,32,121,97)

Then you would need to use GUICtrlSetData($mylist,$Current & "|")

Link to comment
Share on other sites

once again thanks for all that help but just one more question. I got it to work with the listbox but for the life of me i can't get it to create a new gui and populate the list box. This command is running in a main gui but if it detects the attribute O in any of those files, I wanted it to open a new gui and populate the list box inside it. Everything i tried has failed other than creating a list box in the main gui.

Link to comment
Share on other sites

I'm not sure I follow what your doing. Can you try and describe it better

Post the code you have already, I'm logging off now so if I know how to do whatever your trying to do I'll post tomorrow, unless someone else does it before

Link to comment
Share on other sites

Hi,

You could look at brian's search engine which switches GUI to make Listview; and shows switching back again when the second closes;

search_engine_1.5.1.5.3.au3Best, Randall

GUISetState(@SW_HIDE, $mainGUI)

$readdrivecombo = GUICtrlRead($drivecombo)

$searchquierie = GUICtrlRead($searchquierieinput)

$searchGUI = GUICreate("Searching... (Esc cancels)", 800, 600, (@DesktopWidth - 800) / 2, (@DesktopHeight - 600) / 2)

$searchlistView = GUICtrlCreateListView("Filename|Location|Size|Date Modified|Date Created|File Extension", 10, 10, 790, 570)

$statuslabel = GUICtrlCreateLabel("", 10, 580, 790, 20)

etc....
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...