Sign in to follow this  
Followers 0
JustDoIt

Read the name of a file into a string ?

7 posts in this topic

Can someone tell me how to in AutoIt read the name of a file (not the content of the file) into a string ??? TIA.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Explain better. If you dont know the file name, where are the file ?

How do you know the file that you want to know the name ?

Dim $file
Dim $tmp

$file="test.txt"

$tmp=fileread($file)

msgbox(0,"test","This are file contents"&$tmp&" and this are the file name "&$file)
Edited by Kram3r

To all the Devs: Thkx for AutoIt To all Mods: Thkx for the quality forum

Share this post


Link to post
Share on other sites

Explain better. If you dont know the file name, where are the file ?

How do you know the file that you want to know the name ?

Files are created from the run of an application. File name's format is already specified inside the program but the files' names vary depending on the workload. So, I would like to check the names (of the files that are generated after the program's run) to see they are in expected format.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Dim $file
Dim $tmp

$file="test.txt"

$tmp=fileread($file)

msgbox(0,"test","This are file contents"&$tmp&" and this are the file name "&$file)
It returns the file name as "1", while it's actually "test.txt" Edited by JustDoIt

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

You can use for your case:

_FileListToArray ()

Description: Lists files and\or folders in a specified path (Similar to using Dir with the /B Switch)

PS: In my environment the above example returns "test.txt" for the file name.

Edited by Kram3r

To all the Devs: Thkx for AutoIt To all Mods: Thkx for the quality forum

Share this post


Link to post
Share on other sites

_FileListToArray () is what I need. Thanks.

Share this post


Link to post
Share on other sites

You welcome, glad to help you.


To all the Devs: Thkx for AutoIt To all Mods: Thkx for the quality forum

Share this post


Link to post
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
Sign in to follow this  
Followers 0