Search code examples
filerenameautohotkeyautoit

Mass-produce files named by date


Using AutoHotkey or AutoIt I need to create (and name) a database (.db) file in the date format.

The files should be named January/01/2000.db, January/02/2000.db, etc. Right up to the present day; a new file for each day.

Additionally, the created files need to be in a new folder having the same name as the file.


Solution

  • January/01/2000.db is not a valid filename but a folder path! The following AutoHotkey snippet would do it:

    #SingleInstance, Force
    SetWorkingDir %A_ScriptDir%  
    SetBatchLines -1
    
    DatB := 20000101000000
    DatE := SubStr( A_Now,1,8 ) . "000000"
    While ( DatB <= DatE ) {
     FormatTime, DT, %DatB%, MMMM\dd
     FormatTime, YY, %DatB%, yyyy
     DatB += 1, Day
     FileCreateDir, %A_ScriptDir%\%DT%
     FileAppend,, %DT%\%YY%.db
    }