ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > Finished Programs

DONE: Make folder with current date

(1/2) > >>

magician62:
I have searched the net, and found a few ways of doing this, but not they way I envisage.

In the right click menu under 'New', I am looking for an option like 'Folder (today)'

On selection it will create a New empty folder at the location selected, and with the name being

YYYYMMDD (Using the current date)

It might be useful to have configuration of date format for those that may have other uses.

If it already exists, a link would be much appreciated.

MilesAhead:
I don't think you can specifically put an entry in Shell New for a folder without displacing the default New Folder.

What I have is an AHK hotkey to paste the date in the desired format.

Let it sit in the tray.  Use the New => Folder menu in Explorer as usual.  This creates a folder named New folder with the "New folder" text selected.  Press F10 and the date will be pasted in as the name.

You can change the hotkey by specifying another on the command line of DatePaste.

I'm supplying the source. If you wish to change the date format you can either change it in the source or add code to read from .ini file.

It includes a file of general purpose routines named MilesAhead.ahk.

Note that I'm using the latest release of AutoHotkey_L 32 bit unicode to compile.

I think it should compile with plain vanilla ahk, but if you have an issue try the _L version.

DatePaste.ahk


--- ---/*
 * * * Compile_AHK SETTINGS BEGIN * * *

[AHK2EXE]
Exe_File=%In_Dir%\DatePaste.exe
No_UPX=1

* * * Compile_AHK SETTINGS END * * *
*/

; AutoHotkey Script Template for MilesAhead
#SingleInstance force
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
#Include MilesAhead.ahk
progname := _FileBaseName(A_ScriptFullPath)
Menu Tray,NoStandard
Menu Tray,Add,Donate,DoDonate
Menu Tray,Add,Visit Hotkey Page,DoVisit
Menu Tray,Add,About,DoAbout
Menu Tray,Add
Menu Tray,Add,Quit,DoQuit
Menu Tray,Default,About
if (A_IsCompiled)
  Menu Tray,Icon,%A_ScriptFullPath%,1
Menu Tray,Tip,%progname%


if 0 = 1
{
carg = %1%
}
else
{
carg := "F10"
}

GroupAdd,DesktopGroup, ahk_class CabinetWClass
GroupAdd,DesktopGroup, ahk_class ExploreWClass
GroupAdd,DesktopGroup, ahk_class Progman
GroupAdd,DesktopGroup, ahk_class WorkerW

Hotkey, IfWinActive, ahk_Group DesktopGroup
Hotkey,%carg%,DoHotKey,UseErrorLevel
If ErrorLevel
{
  MsgBox, 4112, %progname%, %carg% is not a valid Hotkey
  ExitApp
}
_EmptyWorkingSet()
Return

DoHotKey:
  FormatTime, DateString,A_Now,yyyyMMdd
  ClipSaved := ClipboardAll ; save entire clipboard
  Clipboard =
  Send ^c
  Clipwait,0
  if (Clipboard = "New folder")
  {
    Send %DateString%
    Send {Enter}
  }
  Clipboard := ClipSaved
  ClipSaved = ; free memory
Return

DoAbout:
  FileGetVersion,filever,%progname%.exe
  MyMsg =
  (
%progname% v %filever% Copyright (c) 2011 www.FavesSoft.com`n
After creating a new folder press %carg% to paste the date as name`n
Specify another hotkey on command line if desired`n
  )
  MsgBox, 4160, About %progname%, %MyMsg%
Return

DoDonate:
  Run,"http://www.favessoft.com/donate.html"
Return

DoVisit:
  Run,"http://www.favessoft.com/hotkeys.html"
Return

DoQuit:
  ExitApp

MilesAhead.ahk


--- ---;
; MilesAhead include script with a few system related functions
;

; returns non 0 if program is running
_IsRunning(program)
{
Process,Exist,%program%
Return errorlevel
}

_LoWord(arg)
  {
    Return arg & 0xFFFF
  }

_HiWord(arg)
  {
    Return arg >> 16
  }

_LoByte(arg)
  {
    Return arg & 0x00FF
  }

_HiByte(arg)
  {
    Return (arg & 0xFF00) >> 8
  }

_WinVersionMajor()
  {
    Return _LoByte(_LoWord(DllCall("kernel32.dll\GetVersion", "UInt", -1)))
  }

_WinVersionMinor()
  {
    Return _HiByte(_LoWord(DllCall("kernel32.dll\GetVersion", "UInt", -1)))
  }

_WinVersion()
  {
    dwVersion := DllCall("kernel32.dll\GetVersion", "UInt", -1)
    Return _LoByte(_LoWord(dwVersion)) . "."
    . _HiByte(_LoWord(dwVersion))
  }

;call EmptyWorkingSet in AHK
_EmptyWorkingSet()
  {
    Return DllCall("psapi.dll\EmptyWorkingSet", "UInt", -1)
  }

;reduce memory footprint by calling EmptyWorkingSet
_ReduceMemory()
  {
    If _WinVersionMajor() > 4
    {
      Return _EmptyWorkingSet()
    }
    Return false
  }

;function by HotKeyIt on AHK forums
FormatMessageFromSystem(ErrorCode)
  {
    VarSetCapacity(Buffer, 2000)
    DllCall("FormatMessage"
            , "UInt", 0x1000      ; FORMAT_MESSAGE_FROM_SYSTEM
            , "UInt", 0
            , "UInt", ErrorCode
            , "UInt", 0x800 ;LANG_SYSTEM_DEFAULT (LANG_USER_DEFAULT=0x400)
            , "UInt", &Buffer
            , "UInt", 500
            , "UInt", 0)
    VarSetCapacity(buffer,-1)
    Return Buffer
  }

_GetWorkArea(ByRef left, ByRef top, ByRef right, ByRef bottom)
  {
    VarSetCapacity(work_area,16,0)
    success := DllCall( "SystemParametersInfo", "uint", 0x30, "uint", 0, "uint", &work_area, "uint", 0 )
    If success =
    {
      Return 0
    }
    left := NumGet(work_area,0)
    top := NumGet(work_area,4)
    Right := NumGet(work_area,8)
    Bottom := NumGet(work_area,12)
    Return 1
  }

_MarginWorkArea(ByRef left, ByRef top, ByRef right, ByRef bottom, ByRef margin = 4)
  {
    If _GetWorkArea(left, top, Right, Bottom)
    {
      If Margin is Integer
      {
        If (Margin < 0) or (Margin > 12)
          Margin := 4
      }
      Else
        Margin := 4
      left += Margin
      top += Margin
      Right -= Margin
      Bottom -= Margin
      Return 1
    }
    Return 0
  }

_TaskbarGapArea(ByRef left, ByRef top, ByRef right, ByRef bottom,  percentgap = 5)
{
  _GetWorkArea(left, top, right, bottom)
  If (right - left = A_ScreenWidth) And (bottom - top = A_ScreenHeight)
  {
    Return
  }
  Else If (bottom < A_ScreenHeight)
  {
    bottom -= (bottom // 100 * percentgap)
  }
  Else If (top > 0)
  {
    top += (bottom - top) // 100 * percentgap
  }
  Else If (left > 0)
  {
    left += (right - left) // 100 * percentgap
  }
  Else
 {
    right -= (right - left) // 100 * percentgap
 }
}

_GlassEnabled()
  {
    isEnabled = false
    If _WinVersionMajor() < 6
    {
      Return false
    }
    DllCall("dwmapi.dll\DwmIsCompositionEnabled", "UInt", &isEnabled)
    Return %isEnabled%
  }

_EnableBlurBehind(hwnd)
  {
    VarSetCapacity(struct, 16, 0)
    NumPut(1, struct, 0, "UInt")Â  ; dwFlags=DWM_BB_Enable
    NumPut(1, struct, 4,  "Int")  ; fEnable=TRUE
    DllCall("dwmapi.dll\DwmEnableBlurBehindWindow", "UInt", hwnd, "UInt", &struct)
  }

;returns string, wrapped in quotes when conataining spaces
_WrapQuotes(str)
  {
    If InStr(str," ")
    {
      str := """" . str . """"
    }
    Return str
  }

_FileBaseName(path)
  {
    SplitPath,path,,,,basename
    Return basename
  }

_FileDir(path)
  {
    SplitPath,path,,fdir
    Return fdir
  }

_FileDirWithSlash(path)
  {
    Return _FileDir(path) . "\"
  }

_KillOtherCopies()
{
local nkilled := 0
if !A_IsCompiled
return
PID := DllCall("GetCurrentProcessId")
for proc in ComObjGet("winmgmts:").ExecQuery("Select * from Win32_Process")
    if (proc.Name = A_ScriptName) && (proc.ProcessID != PID)
{
PPID := proc.ProcessID
;MsgBox, 4160, , Killing %PPID%, 2
Process,close,%PPID%
nkilled += 1
}
return nkilled
}

_CheckForUpdate(url="http://www.favessoft.com/",ininame="FavesVersions.ini")
  {
    urlfile := url . ininame
    localfile := A_ScriptDir . "\" . ininame
    param := _FileBaseName(A_ScriptFullPath)
    If (FileExist(localfile))
    {
      FileDelete,%localfile%
    }
    ;MsgBox, 4160, , localfile is %localfile%
    URLDownloadToFile,%urlfile%,%localfile%
    If ErrorLevel
    {
      MsgBox, 4112, %param%, Server access failed!
      Return
    }
    IniRead,onlinever,%localfile%,Versions,%param%,%A_Space%
    IniRead,zipfile,%localfile%,Downloads,%param%,%A_Space%
    FileGetVersion,localver,%A_ScriptFullPath%
    If localver =
    {
      MsgBox, 4112, %param%, local Version Info Not Found!
      Return
    }
    If onlinever =
    {
      MsgBox, 4112, %param%, Online Version Info Not Found!
      Return
    }
    ;MsgBox, 4160, URLDown Online Verson, %onlinever%
    ;MsgBox, 4160, URLDown local Verson, %localver%

    If (onlinever > localver)
    {
      If zipfile =
      {
        MsgBox, 4112, %param%, Could not determine Download Filename!
        Return
      }
      MsgBox, 0x1024, %param%, Current Version is %localver% : Download %onlinever% ?
      IfMsgBox Yes
      {
        urlfile := url . zipfile
        ziplocalfile := A_ScriptDir . "\" . zipfile
        URLDownloadToFile,%urlfile%,%ziplocalfile%
        If ErrorLevel
        {
          MsgBox, 4112, %param%, Download attempt failed!!
          Return
        }
        Run,%ziplocalfile%
        Run,%A_ScriptDir%
        If (FileExist(localfile))
        {
          FileDelete,%localfile%
        }
        ExitApp
      }
    }
    Else
    {
      MsgBox, 4160, %param%, %localver% is the Latest Version
    }
    If (FileExist(localfile))
    {
      FileDelete,%localfile%
    }
    Return
  }

scancode:
Folder (Today)
creates a folder with the current date as nameWhat's new in v1.0?
[*] App is born.[/list]
Have fun!Download

(VB6 runtimes required on Windows 9x/NT/2000)

magician62:
Thank you both for the replies. I have installed scancode's solution, and it works perfect for my needs.  :Thmbsup:

MilesAhead, your solution was an interesting approach, and has given me more insight into ahk, code examples are good, as it helps me to understand how something is done, allowing for possible extrapolation at a later date, when I can get my head around how it works.

Maybe the next generation will detect my thoughts for the need of a folder and create it with the name I am thinking at the time  :D

MilesAhead:
I took a look at the registry approach. I don't like to use registry unless it gives some big benefit, such as allowing a program to process all files in a folder or all selected files. Also for me right click usually slows me down.  SendTo is OK for some things though.  But everyone has their own prerferences.

I was being just a bit facetious. I have a tough time with AHK, esp. string handling. After some struggle I figured out how to append the date name onto the current folder or paste in the desktop. For desktop I cheat and just use a bunch of Send marcros. :) It all happens with one key press.



The new DatePaste.ahk


--- ---/*
 * * * Compile_AHK SETTINGS BEGIN * * *

[AHK2EXE]
Exe_File=%In_Dir%\DatePaste.exe
No_UPX=1

* * * Compile_AHK SETTINGS END * * *
*/

; AutoHotkey Script Template for MilesAhead
#SingleInstance force
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
#Include MilesAhead.ahk
progname := _FileBaseName(A_ScriptFullPath)
Menu Tray,NoStandard
Menu Tray,Add,Donate,DoDonate
Menu Tray,Add,Visit Hotkey Page,DoVisit
Menu Tray,Add,About,DoAbout
Menu Tray,Add
Menu Tray,Add,Quit,DoQuit
Menu Tray,Default,About
if (A_IsCompiled)
  Menu Tray,Icon,%A_ScriptFullPath%,1
Menu Tray,Tip,%progname%

if 0 = 1
{
carg = %1%
}
else
{
carg := "F10"
}

GroupAdd,DesktopGroup, ahk_class CabinetWClass
GroupAdd,DesktopGroup, ahk_class ExploreWClass
GroupAdd,DesktopGroup, ahk_class Progman
GroupAdd,DesktopGroup, ahk_class WorkerW

Hotkey, IfWinActive, ahk_Group DesktopGroup
Hotkey,%carg%,DoHotKey,UseErrorLevel
If ErrorLevel
{
  MsgBox, 4112, %progname%, %carg% is not a valid Hotkey
  ExitApp
}
_EmptyWorkingSet()
Return

; Create folder with Date as name
DoHotKey:
WinGetTitle,title,A
FormatTime, DateString,A_Now,yyyyMMdd
;MsgBox, 4160, , Window Title is: %title%, 2
if (title = "Program Manager")
{
Send {RButton}
Sleep,10
Send w
Sleep,10
Send f
Sleep,10
Send %DateString%
Send {Enter}
}
else
{
StringRight,lastchar,title,1
if (lastchar != "\")
fname := title . "\" . DateString
else
fname := title . DateString
FileCreateDir,%fname%
if errorlevel
MsgBox, 4112, , Creation of Folder: %fname% Failed!
}
_EmptyWorkingSet()
Return

DoAbout:
  FileGetVersion,filever,%progname%.exe
  MyMsg =
  (
%progname% v %filever% Copyright (c) 2011 www.FavesSoft.com`n
While Desktop or Explorer Window is active`n Press %carg% to create a folder with Date as name`n
Specify another hotkey on command line if desired`n
  )
  MsgBox, 4160, About %progname%, %MyMsg%
Return

DoDonate:
  Run,"http://www.favessoft.com/donate.html"
Return

DoVisit:
  Run,"http://www.favessoft.com/hotkeys.html"
Return

DoQuit:
  ExitApp

Navigation

[0] Message Index

[#] Next page

Go to full version