Jump to content

Recommended Posts

Posted (edited)

_FileListToArray()

; OR

_FileListToArrayRec()

Edited by guinness

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

You'll also want to look at DriveGetDrive too as well as FileExists and loops and conditional statements.

Here is a basic example how to tell if a folder is ina root c drive.

If FileExists("C:\Folder") Then
    Exit MsgBox(0,0, "File exists")
EndIf

MsgBox(0,0, "File not exists")

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Posted (edited)

_FileListToArrayRec() does, unless I am mistaken, oh no! Maybe we should both read the help file to see which of us is right or wrong.

Edited by guinness

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

If you do not know which unit is, use DriveGetDrive("all") + FileExists ()

Local $i = 0, $file, $search
$file = "WINDOWS"; Example (Name of the file or folder)
$search = DriveGetDrive("all"); List all units
If not @error Then
For $i = 1 To $search[0]
If FileExists($search[$i] & "\" & $file) Then _
MsgBox(4096, "Test", "The file is on drive " & $search[$i] & "\", 5)
Next
EndIf
Posted (edited)
  Quote

 

Here is a 'help forum', not a 'code on demand' forum.

 

yes I know but anyone don't say me how can search complete drive.

 

  Quote
Local $i = 0, $file, $search $file = "WINDOWS"; Example (Name of the file or folder) $search = DriveGetDrive("all"); List all units If not @error Then For $i = 1 To $search[0] If FileExists($search[$i] & "\" & $file) Then _ MsgBox(4096, "Test", "The file is on drive " & $search[$i] & "\", 5) Next EndIf

 

Thanks Belini, but your code search only root Drive. :x

Edited by Table
Posted (edited)

Try this other: 

#include <Array.au3>
Global $path, $search, $found

$path = FileSelectFolder("looking folder.", ""); Drive or folder to search
If StringLen($path) = 3 Then $path = StringMid($path, 1, 2)

$search = InputBox("Make demand", "Enter the name of the file or folder to search.", "explorer.exe"); Name of the file or folder
list($path, 0)

$show = StringSplit($found, "|", 0)
_ArrayDisplay($show, "Files found")

Func list($path = "", $counter = 0)
    $counter = 0
    $path &= '\'
    Local $list_files = '', $file, $demand_file = FileFindFirstFile($path & '*')
    If $demand_file = -1 Then Return ''
    While 1
        $file = FileFindNextFile($demand_file)
        If @error Then ExitLoop
        If @extended Then
            If $counter >= 10 Then ContinueLoop
            list($path & $file, $counter + 1)
            If $path & $file = $path & $search Then $found &= $path & $file & "|"
        Else
            If $path & $file = $path & $search Then $found &= $path & $file & "|"
        EndIf
    WEnd
    FileClose($demand_file)
EndFunc   ;==>list
Edited by Belini
Posted

Belini's code could possible fail, you just don't know when due to recursion. You should search that too.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

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