svaneenoo Posted March 5, 2010 Share Posted March 5, 2010 Hi all, I am trying to copy and rename a file. This works fine, however, I want to add the current date to the filename. e.g. docname05/04/10 16:50:23.doc I am able to get the new name concatenated with the current date in a message box, but it does not work with the filecopy function. Here is my code. Hope somebody can help me. I have also attached the script. #include <Date.au3> $tCur = _Date_Time_GetSystemTime() If FileExists("C:\Program Files\Rwd uPerform\Client\bin\uPerform1.exe")=0 Then FileCopy(@ProgramFilesDir &"\Rwd uPerform\Client\bin\uPerform.exe",@ProgramFilesDir &"\Rwd uPerform\Client\bin\uPerform1" &_Date_Time_SystemTimeToDateTimeStr($tCur)& ".exe",0) Run (@ProgramFilesDir &"\Rwd uPerform\Client\bin\uPerform1.exe") Else Run("C:\Program Files\Rwd uPerform\Client\bin\uPerform1.exe") EndIfuRecord_uPerform.au3 Link to comment Share on other sites More sharing options...
martin Posted March 5, 2010 Share Posted March 5, 2010 The destination file name contains spaces so you need to wrap the whole path in quotation marks. FileCopy(@ProgramFilesDir &"\Rwd uPerform\Client\bin\uPerform.exe",'"'@ProgramFilesDir &'\Rwd uPerform\Client\bin\uPerform1' &_Date_Time_SystemTimeToDateTimeStr($tCur) & '.exe"',0) Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
svaneenoo Posted March 5, 2010 Author Share Posted March 5, 2010 Hi, I have tried your code, but now i am getting syntax errors. Any suggestion? Best regards, Stefaan Link to comment Share on other sites More sharing options...
PhilipG Posted March 5, 2010 Share Posted March 5, 2010 FileCopy(@ProgramFilesDir &"\Rwd uPerform\Client\bin\uPerform.exe",'"' & @ProgramFilesDir &'\Rwd uPerform\Client\bin\uPerform1' &_Date_Time_SystemTimeToDateTimeStr($tCur) & '.exe"',0) Try that one Link to comment Share on other sites More sharing options...
svaneenoo Posted March 5, 2010 Author Share Posted March 5, 2010 I shouted too soon. The file was not created, and the editor returned the following message. >"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Users\rwd_eenoo\Desktop\uRecord_uPerform.au3" Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now