Jump to content

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

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

EndIf

uRecord_uPerform.au3

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