Jump to content

Getting a directory name when only part of it is known


JonF
 Share

Recommended Posts

I have a situation in which there is a directory containing a whole bunch of directories, each containing files I need to copy (by writing a script file for another language). I know the entire path except the last few characters of the last directory name. These last few characters follow an underscore. I tried:

; $CmdLine[1] is the path to the set of directories
For $i = 0 To (UBound($DriverNames) - 1)
  $SearchHandle =FileFindFirstFile($CmdLine[1] & $DriverNames[$i] & "_*")
  If $SearchHandle Then
    FileWriteLine($FileHandle,"FileCopy," & $FileFindNextFile($SearchHandle) & "*.*,%Target_Win%\Inf")
    FileClose($SearchHandle)
  EndIf
Next

The If test is true, but FileFindNextFile returns a null string. What am I missing?

Edited by JonF
Link to comment
Share on other sites

I have a situation in which there is a directory containing a whole bunch of directories, each containing files I need to copy (by writing a script file for another language). I know the entire path except the last few characters of the last directory name. These last few characters follow an underscore. I tried:

; $CmdLine[1] is the path to the set of directories
For $i = 0 To (UBound($DriverNames) - 1)
  $SearchHandle =FileFindFirstFile($CmdLine[1] & $DriverNames[$i] & "_*")
  If $SearchHandle Then
    FileWriteLine($FileHandle,"FileCopy," & $FileFindNextFile($SearchHandle) & "*.*,%Target_Win%\Inf")
    FileClose($SearchHandle)
  EndIf
Next

The If test is true, but FileFindNextFile returns a null string. What am I missing?

Hi,

just a: If $SearchHandle <> -1 Then

;-))

Stefan

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