Jump to content

How to grab the variable when loading a directory.


Recommended Posts

Please help with the following question..

Everything works fine with exception of the data in the asterisks below.

What I am trying to do is simply grab the name of each file as it comes in and I need the file in a variable so I can do a Send command with it. But any way that I try to grab the variable from $file it end up with an error.

What syntax do i need to get each incoming file name from $file into a regular variable so I can use it like so:

Send($myvariable)

$mydir = "C:\autoit_work_folder\ewi\"

FileChangeDir($mydir)

; Shows the filenames of all files in the current directory.

$search = FileFindFirstFile("*.txt")

While 1

$file = FileFindNextFile($search)

If @error Then ExitLoop

MsgBox(4096, "File Name:", $file)

; *******************************

$myfile = (4096, "File Name:", $file)

MsgBox($myfile)

; *******************************

WEnd

FileClose($search)

Link to comment
Share on other sites

Please help with the following question..

Everything works fine with exception of the data in the asterisks below.

What I am trying to do is simply grab the name of each file as it comes in and I need the file in a variable so I can do a Send command with it. But any way that I try to grab the variable from $file it end up with an error.

What syntax do i need to get each incoming file name from $file into a regular variable so I can use it like so:

Send($myvariable)

$mydir = "C:\autoit_work_folder\ewi\"

FileChangeDir($mydir)

; Shows the filenames of all files in the current directory.

$search = FileFindFirstFile("*.txt")

While 1

$file = FileFindNextFile($search)

If @error Then ExitLoop

MsgBox(4096, "File Name:", $file)

; *******************************

$myfile = (4096, "File Name:", $file)

MsgBox($myfile)

; *******************************

WEnd

FileClose($search)

Im confused at what your are trying to do, but try declaring another var equal to $file.

$mydir = "C:\autoit_work_folder\ewi\"
FileChangeDir($mydir)
; Shows the filenames of all files in the current directory.
$search = FileFindFirstFile("*.txt") 
While 1
$file = FileFindNextFile($search) 
If @error Then ExitLoop
;MsgBox(4096, "File Name:", $file)

; *******************************
$myfile = $file
MsgBox(0, "test", $myfile)
; *******************************

WEnd
FileClose($search)

Edit: changed the dir back to your test dir.

Edited by EndFunc
EndFuncAutoIt is the shiznit. I love it.
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...