How to add timestamp to a backup file ?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
hancre
Posts: 248
Joined: 02 Jul 2021, 20:51

How to add timestamp to a backup file ?

20 Sep 2021, 01:13

When I create a backup file, I want to add timestap to the filename ?

I tried this following code. But it doesn't work.

Code: Select all

#bs::
FormatTime, T, %A_Now%, yyyyMMdd_HHmm ; 201107-25 / yyyy-MM-dd 2011-07-25
FileCopy, *.*, d:\backup\*_%T%.*
return


How can i fix the issue? Thanks for any help in advance.
Rohwedder
Posts: 7680
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: How to add timestamp to a backup file ?

20 Sep 2021, 03:00

Hallo,
here it works.
hancre
Posts: 248
Joined: 02 Jul 2021, 20:51

Re: How to add timestamp to a backup file ?

20 Sep 2021, 03:31

Rohwedder wrote:
20 Sep 2021, 03:00
Hallo,
here it works.
I think you miss your code. ^^;;
Thank you for your help.
Rohwedder
Posts: 7680
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: How to add timestamp to a backup file ?

20 Sep 2021, 04:01

I had used your code! This (so yours) has done here (in my opinion) what you wanted!
hancre
Posts: 248
Joined: 02 Jul 2021, 20:51

Re: How to add timestamp to a backup file ?

20 Sep 2021, 04:12

Rohwedder wrote:
20 Sep 2021, 04:01
Thanks for your help.
In my computer, the same thing often happens.
( In others computer, works.. But it doesn't work in my notebook. )
Rohwedder
Posts: 7680
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: How to add timestamp to a backup file ?

20 Sep 2021, 04:15

Try with admin rights:

Code: Select all

#SingleInstance, Force
If !A_IsAdmin
	Try Run *RunAs "%A_ScriptFullPath%"
#bs::
FormatTime, T, %A_Now%, yyyyMMdd_HHmm ; 201107-25 / yyyy-MM-dd 2011-07-25
FileCopy, *.*, d:\backup\*_%T%.*
return
hancre
Posts: 248
Joined: 02 Jul 2021, 20:51

Re: How to add timestamp to a backup file ?

20 Sep 2021, 05:40

Rohwedder wrote:
20 Sep 2021, 04:15
Thank you for your help again.
It works as admin. But it copies what I didn't want.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], peter_ahk, Rohwedder, Spawnova and 158 guests