Jump to content
Sign in to follow this  

Rename file and add current date to filename

Recommended Posts


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")

 Run("C:\Program Files\Rwd uPerform\Client\bin\uPerform1.exe")



Share this post

Link to post
Share on other sites

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.

Share this post

Link to post
Share on other sites


I have tried your code, but now i am getting syntax errors.

Any suggestion?

Best regards,


Share this post

Link to post
Share on other sites

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"

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  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.