Sign in to follow this  
Followers 0
kertofer

Calling a filename?

13 posts in this topic

Hi all, I am new to Autoit scripting and I am trying to use a variable to call a filename and am not sure of the syntax to do so.

For example I have a variable which is $UserName and I have a file in a directory that is called UserName.ini I want Autoit to grab the $Username variable, append .ini to it and copy that file over another file.

Can someone help me out with the proper syntax for this?

Thanks in advance!

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

Welcome to the forums!

I'm not sure what you mean, but try looking at these functions:

FileWrite

FileWriteLine

IniWrite

FileCopy

Please let me know wether this is helpful :)

Edited by theguy0000

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Share this post


Link to post
Share on other sites

[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

HEre is what I am doing:

$FilePath = (C:\program files\files\)

$Username = 'kertofer'

FileCopy = ($FilePath\$Username.ini,$FilePath\filename.ini,1)

What I am trying to accomplish is getting a group of files that can be copied over the main configuration file by using an AutoIt script.

Share this post


Link to post
Share on other sites

maybe

$FilePath = "C:\program files\files\"
$Username = "kertofer"

FileCopy = ($FilePath & $Username & ".ini" , $FilePath & "filename.ini",1)

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Here is the error I get now:

Error:Error parsing function call

This error is thrown on the line with the FileCopy function in it.

Share this post


Link to post
Share on other sites

maybe

$FilePath = "C:\program files\files\"
$Username = "kertofer"

FileCopy = ($FilePath & $Username & ".ini" , $FilePath & "filename.ini",1)

8)

Since when do you set something equal to a function call?

$FilePath = "C:\program files\files\"
$Username = "kertofer"

FileCopy ($FilePath & $Username & ".ini" , $FilePath & "filename.ini",1)

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

ooopps!... twice today

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

then one of your files/folders is not there/correct

8)

What are you talking about? Did you reread your code you posted, and then the code I posted? Did you notice something different between the way you were calling the function and the way I was? That's where your error is.

Share this post


Link to post
Share on other sites

I got this to work, I created a simple DOS batch file within the files directory and had it copy the files the way I want them then in my AutoIt script I call that batch as follows:

Run($FilePath & $Username & ".bat",$FilePath)

This works, it is just something in that FileCopy function call that is not working and I am too much of a newb to figure out what it is.

Share this post


Link to post
Share on other sites

GreenMachine, you were right, I did not see that equal sign in the FileCopy funchtion line, that got it working!

Thanks a lot all!

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

... I did not see that equal sign in the FileCopy funchtion line...

yea... then i followed your lead...

Dah!

8)

Edited by Valuater

NEWHeader1.png

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