topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Thursday March 28, 2024, 4:25 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: DONE: Make folder with current date  (Read 14233 times)

magician62

  • Supporting Member
  • Joined in 2011
  • **
  • Posts: 178
    • View Profile
    • Donate to Member
DONE: Make folder with current date
« on: August 01, 2011, 09:56 AM »
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.
Why an I Magician62? Because Magician1 thru 61 were gone. :)

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: IDEA: Make folder with current date
« Reply #1 on: August 01, 2011, 01:37 PM »
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
  }
« Last Edit: August 01, 2011, 04:44 PM by MilesAhead »

scancode

  • Honorary Member
  • Joined in 2007
  • **
  • Posts: 641
  • I will eat Cody someday.
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: IDEA: Make folder with current date
« Reply #2 on: August 02, 2011, 12:59 AM »
Folder (Today)
creates a folder with the current date as name

screenshot.jpg

What's new in v1.0?
    • App is born.
    Have fun!

    Download

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

    magician62

    • Supporting Member
    • Joined in 2011
    • **
    • Posts: 178
      • View Profile
      • Donate to Member
    Re: IDEA: Make folder with current date
    « Reply #3 on: August 02, 2011, 02:13 AM »
    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
    Why an I Magician62? Because Magician1 thru 61 were gone. :)

    MilesAhead

    • Supporting Member
    • Joined in 2009
    • **
    • Posts: 7,736
      • View Profile
      • Donate to Member
    Re: IDEA: Make folder with current date
    « Reply #4 on: August 02, 2011, 05:16 PM »
    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

    nogojoe

    • Charter Member
    • Joined in 2006
    • ***
    • Posts: 169
      • View Profile
      • Donate to Member
    Re: DONE: Make folder with current date
    « Reply #5 on: August 06, 2011, 05:50 PM »
    Folder (Today)
    creates a folder with the current date as name


    What's new in v1.0?
      • App is born.
      Have fun!

      Download  (see attachment in previous post)
      (VB6 runtimes required on Windows 9x/NT/2000)

      Hi Scancode    Have installed your app   but i am getting no item installed on the right click context menu
      Am running Win XP SP3
      Any suggestions
      Often the most convincing people are those who have lost the plot so much they don't recognize the difference between fact and fantasy

      skwire

      • Global Moderator
      • Joined in 2005
      • *****
      • Posts: 5,286
        • View Profile
        • Donate to Member
      Re: DONE: Make folder with current date
      « Reply #6 on: August 06, 2011, 07:13 PM »
      Hi Scancode    Have installed your app   but i am getting no item installed on the right click context menu
      Am running Win XP SP3
      Any suggestions

      This application doesn't put an entry in the standard context menu you see when you right click files or folders.  This puts an entry in the "New" menu that you see when you right-click a blank area in a Windows Explorer window.  Does that help clear things up?

      fenixproductions

      • Honorary Member
      • Joined in 2006
      • **
      • Posts: 1,186
        • View Profile
        • Donate to Member
      Re: DONE: Make folder with current date
      « Reply #7 on: August 08, 2011, 02:31 AM »
      It seems I am too late with XMD

      Winkie

      • Supporting Member
      • Joined in 2008
      • **
      • Posts: 93
        • View Profile
        • Donate to Member
      Re: DONE: Make folder with current date
      « Reply #8 on: August 08, 2011, 02:22 PM »
      It seems I am too late with XMD
      -fenixproductions (August 08, 2011, 02:31 AM)
      It's never too late to suggest good software :D. I love software with a lot of (command line) parameters...  :tellme:
      So XMD is bookmarked for reference. For now I have enough with XYplorer's New Templates:
      XYplorer New Templates.pngDONE: Make folder with current date