Sign in to follow this  
Followers 0
Curtiss W.

Copy and renmae using a variable

4 posts in this topic

Ok can you use a variable when you copy a file to change the name? Can you do it on the fly or do you have to rename the file first and then copy it? See Below.

FileCopy ( @homedrive &"\Documents and Settings\user\Desktop\autoit-temp\a\test.bat" , @homedrive &"\Documents and Settings\user\Desktop\autoit-temp\b\ @computername & -test.bat", 9)

In this case when the file is copied from floder a to folder b I need to add the computer name to the front of the file name. so it starts off as test.bat but need to end up as %computer%-test.bat

Thanks is advance for any help.

Curtiss W.

Share this post


Link to post
Share on other sites



I don't think you can rename during a filecopy. I believe you need to do a filemove to rename. For what you have, it'll look like this:

FileCopy ( @homedrive &"\Documents and Settings\user\Desktop\autoit-temp\a\test.bat", @TempDir, 9)
FileMove(@TempDir & "\test.bat", @HomeDrive & "\Documents and Settings\user\Desktop\autoit-temp\b\" & @ComputerName & "-test.bat", 9)

Share this post


Link to post
Share on other sites

Curtiss, why didn't you just this yourself ? I don't see a reason for you to ask this question

here really, when you could have found it out in like 10 seconds. Anyway, the answer is yes.

Share this post


Link to post
Share on other sites

Well I'll be... It looks like you can rename during a copy. I didn't think you could since the help file says "Because AutoIt lacks a "FileRename" function, use FileMove to rename a file!"

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