Jump to content

Copy and renmae using a variable


Recommended Posts

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.

Link to comment
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)
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...