Sign in to follow this  
Followers 0
TonyP

Output expression as text

5 posts in this topic

Okay so this may sound dumb, but I'm trying to grab a large amount of file names and write them to a txt file. I figured out how to do that and figured why not take it a step further. So I am now trying to figure out how to output a expression. For instance if I grab a filename called "stuff.exe" and output it into a txt file, it will show up as "stuff.exe" but how can I make it show up like this in the text file?

FileInstall ("stuff.exe", "stuff.exe")

Is there a way to do that?

Thanks

Code so far below:

; Shows the filenames of all files in the current directory
$search = FileFindFirstFile("*.exe")  

; Check if the search was successful
If $search = -1 Then
    MsgBox(0, "Error", "No files/directories matched the search pattern")
    Exit
EndIf

$file = FileOpen("updates.txt", 2)

; Check if file opened for writing OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

FileWrite($file, "List of files in this directory with a exe extension:" & @CRLF)

While 1
    $filename = FileFindNextFile($search)
    If @error Then ExitLoop
    FileWrite($file, $filename & @CRLF)
WEnd

; Close the search handle
FileClose($search)

MsgBox(4096, "Complete", "Filenames are listed in updates.txt")

Share this post


Link to post
Share on other sites



While 1
    $filename = FileFindNextFile($search)
    If @error Then ExitLoop
    FileWrite($file, 'FileInstall (""'&$filename&'"", ""'&$filename&'"")'&@CRLF)
WEnd

The key here is using double-quotes to "tell"AutoIt how to deal with them.


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

Oh, double quotations, I hadn't' thought of that. Thanks I will try playing around with that then.

Share this post


Link to post
Share on other sites

Oh, double quotations, I hadn't' thought of that. Thanks I will try playing around with that then.

Just in case you're actually to do a list of files to install, you may want to check this out: http://www.autoitscript.com/forum/index.ph...c=34805&hl=

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

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