Current Date as a Directory name Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Skyyh

Current Date as a Directory name

12 Jul 2017, 11:44

Hi,

I’d like to create directory in my root C: and name it “! 07-12-17” which I can do. But I want Change the date every day to the new date of the day, then compile the script and put in my RUN command in the registry. That way when boot up first thing in the morning or otherwise the current date is in my root C: directory. And I want to replace the Directory not a many Directories with older dates. Needles to say I’m not that far along with AutoHotKey.

I very much appreciate you help. :?:
Sam_
Posts: 146
Joined: 20 Mar 2014, 20:24

Re: Current Date as a Directory name

13 Jul 2017, 13:31

Use at your own risk!

Code: Select all

#Persistent

SetTimer, UpdateFolder, 300000 ; Check ~ every 5 min
Return


UpdateFolder(){
	FormatTime, Today, , ! MM-dd-yy ; Format today's date in the format you specified
	Loop, C:\*, 2, 0 ; Loop through the folders on the top level of the C drive
		{
		SplitPath, A_LoopFileLongPath, OutFileName, OutDir ; Split the current folder's long path into sections
		If RegExMatch(OutFileName,"^! [0-9]{2}-[0-9]{2}-[0-9]{2}$") ; Check to see if the folder we are on is the one formatted the way we want
			{
			FileMoveDir, %A_LoopFileLongPath%, %OutDir%\%Today%, R ; If it is, rename it using today's date, formatted above
			Break ; If the proper folder has been found, stop searching additional folders on the C drive
			}
		}
}
SkyByDay
Posts: 3
Joined: 12 Jul 2017, 11:38

Re: Current Date as a Directory name

13 Jul 2017, 18:10

Sam_
Thank you. I'll try the script.
SkyByDay
Posts: 3
Joined: 12 Jul 2017, 11:38

Re: Current Date as a Directory name

15 Jul 2017, 09:24

Sam_
It worked in 3 of my PC's. THANK you. I was trying to do this four years!

But on my MAC Book Pro 4.1 with Windows 7-64 Ultimate installed I get the following error and the script won't compile:
Error: Target label does not exist

Line#

012: SetTimer, UpdateFolder, 300000

I scratch my bard old dude wooden head and can't figure out why. But if I can't get an answer on the forum that is perfectly ok. I use that laptop very little. It really doesn't matter if the date does update with AHK. I so thankful that I can run it on my PC's.
Sam_
Posts: 146
Joined: 20 Mar 2014, 20:24

Re: Current Date as a Directory name  Topic is solved

15 Jul 2017, 10:54

Sounds like you are using an older version of AHK. You need at least v1.1.20 for SetTimer to use a function instead of a label (which is what I have done).
SkyByDay
Posts: 3
Joined: 12 Jul 2017, 11:38

Re: Current Date as a Directory name

15 Jul 2017, 13:47

Sam_
You were right I had a 2009 version AHK installed. The script works fine now.
Thanks again!!!!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Descolada, lmstearn, roeleboele, ulysim and 378 guests