Jump to content

Searching for a file


jben
 Share

Recommended Posts

Hi,

Does anyone here know if its possible to search for a certain file and then run it if it exists..

Trying to work this out because I have an automated installation in place, but wanted to allow the user to insert a removable device before proceeding, which contains a file called copychart.exe. This file will be copied to the c:\something dir if its found.

Anyone have any ideas. I would think that 1 thing thats important is that it doesn't search the C: drive as this is not necessary as the file will always be stored on D,E,F,G etc...

thanks

Link to comment
Share on other sites

1) DriveGetDrive to get drives, use with "REMOVABLE"?

2 a) Fixed path? e.g. root of device?

-> FileExists

b.) Do a recursive search (look in forum for example)

Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

Hi,

Does anyone here know if its possible to search for a certain file and then run it if it exists..

Trying to work this out because I have an automated installation in place, but wanted to allow the user to insert a removable device before proceeding, which contains a file called copychart.exe. This file will be copied to the c:\something dir if its found.

Anyone have any ideas. I would think that 1 thing thats important is that it doesn't search the C: drive as this is not necessary as the file will always be stored on D,E,F,G etc...

thanks

Quick and dirty - Only checks the root of the drive. You can add folder recursion with some of the other content in the help file (_FileListToArray(), etc):

$sSearchFile = "file.txt"
$aRemovableDrives = DriveGetDrive("REMOVABLE")

If IsArray($aRemovableDrives) Then
    For $i = 1 To $aRemovableDrives[0]
        If FileExists($aRemovableDrives[$i] &"\file.txt") Then
            MsgBox(64,"Found it","Found the file '" &$sSearchFile &"' on drive " &$aRemovableDrives[$i])
            ExitLoop
        EndIf
    Next
EndIf

- MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]

Link to comment
Share on other sites

ahh i see why. I presume this is also checking my CD drives..Seems to show the error message a couple of times.

Actually, there's a separate parameter to handle CD drives ("CDROM" instead of "REMOVABLE"), though I don't know offhand what would be triggering the error noted in your earlier post.

- MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]

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