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

DonationCoder.com Software > Post New Requests Here

IDEA: AHK script to insert date and time to file name

<< < (3/4) > >>

rjbull:
it would rather copy to the clipboard the ISO formatted timestamp-metaDCoder (February 16, 2014, 04:37 PM)
--- End quote ---
You might like to look at Horst Schaeffer's freeware Calendar which allows you to roll your own formats and have them available from a drop-down.  E.g.:
IDEA: AHK script to insert date and time to file name      IDEA: AHK script to insert date and time to file name

tomos:
Hi, I wonder if you could maybe mod this:

--- ---^+d::  ; Ctrl+Shift+d outputs current date+time
   FormatTime, CurrentDateTime,, yyyy-MM-dd HHmm  ; It will look like 2010-12-21 0353hrs
   SendInput %CurrentDateTime%hrs
   return

So that it would rather copy to the clipboard the ISO formatted timestamp as given by attributes/properties (rather than CURRENT timestamp).
-metaDCoder (February 16, 2014, 04:37 PM)
--- End quote ---

FWIW, I have an older script (2008...)
[edit] which did something completely different :-[ (pasted current date/time [/edit]

metaDCoder:
Hi guys, I just wanted to thank you for your comments and suggestions concerning my question (of inserting attributes:time_stamp into the clipboard, and eventually filename).   :)

@IainB - I appreciate the references on the proper functions to use. I don't think it will be so hard now for me to write a functioning script.  Check out http://www.autohotkey.com/board/topic/80479-get-file-path-for-files-on-desktop/ for a super-simple method of retrieving file-path. Note that that script breaks if trying to use the hot-key with no file/folder selected.

IainB:
@metaDCoder: Ah, thanks for that link to http://www.autohotkey.com...ath-for-files-on-desktop/
I shall write/try out a script for this idea and post it here when I get it to work.

4wd:
Don't know if you're familiar with AutoIt but I just added a few lines to a script I modified here.

Only for Explorer.  (Most decent file managers would do this type of thing already, ie. insert file dates, meta data into a rename function.)

Shift+Alt+V - copies the file path/name of the first selected item in an Explorer window, (file or folder), or if nothing is selected then it copies the current Explorer path to the clipboard.

Shift+Alt+D - copies the MODIFIED date of the selected item, (or Explorer path if nothing selected), into the clipboard in Universal format: YYYYMMDD HHMMSS  (NOTE: Won't capture the date of root directories.)

The hotkeys, type of date retrieved, and it's output format could all be changed in the source.


--- Code: AutoIt ---#region ;**** Directives created by AutoIt3Wrapper_GUI ****#AutoIt3Wrapper_UseUpx=n#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****; http://www.autoitscript.com/forum/topic/89833-windows-explorer-current-folder/page__st__40#entry973904#include <Array.au3> HotKeySet('+!v', '_HK_Path') ; Shift+Alt+VHotKeySet('+!d', '_HK_Date') ; Shift+Alt+D Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ComErrFunc") While 1        Sleep(100)WEnd Func _HK_Path()        _ExClip(False)EndFunc   ;==>_HK_Path Func _HK_Date()        _ExClip(True)EndFunc   ;==>_HK_Date Func _ExClip($temp)        $hExplr = WinActive("[REGEXPCLASS:(Explore|Cabinet)WClass]")        If $hExplr <> '' Then                $aSelection = _ExplorerWinGetSelectedItems($hExplr);~              _ArrayDisplay($aSelection)                If $aSelection[0] = 0 Then                        If StringLeft($aSelection[1], 2) <> '::' Then                                If Not $temp Then                                        ClipPut($aSelection[1])                                Else                                        $sDate = FileGetTime($aSelection[1], 0, 1) ; Get MODIFIED date (0), change 0 to 1 for CREATED, 2 for ACCESSED                                        ClipPut(StringLeft($sDate, 8) & " " & StringMid($sDate, 9))                                EndIf                        EndIf                Else                        If Not $temp Then                                ClipPut($aSelection[2])                        Else                                $sDate = FileGetTime($aSelection[2], 0, 1) ; Get MODIFIED date (0) (0), change 0 to 1 for CREATED, 2 for ACCESSED                                ClipPut(StringLeft($sDate, 8) & " " & StringMid($sDate, 9))                        EndIf                EndIf        EndIfEndFunc   ;==>_ExClip   ; ========================================================================================================================== ; Func _ObjectSHFolderViewFromWin($hWnd);; Returns an 'ShellFolderView' Object for the given Window handle;; Author: Ascend4nt, based on code by KaFu, klaus.s; ========================================================================================================================== Func _ObjectSHFolderViewFromWin($hWnd)        If Not IsHWnd($hWnd) Then Return SetError(1, 0, 0)        Local $oShell, $oShellWindows, $oIEObject, $oSHFolderView         ; Shell Object        $oShell = ObjCreate("Shell.Application")        If Not IsObj($oShell) Then Return SetError(2, 0, 0)         ;   Get a 'ShellWindows Collection' object        $oShellWindows = $oShell.Windows()        If Not IsObj($oShellWindows) Then Return SetError(3, 0, 0)         ;   Iterate through the collection - each of type 'InternetExplorer' Object         For $oIEObject In $oShellWindows                If $oIEObject.HWND = $hWnd Then                        ; InternetExplorer->Document = ShellFolderView object                        $oSHFolderView = $oIEObject.Document                        If IsObj($oSHFolderView) Then Return $oSHFolderView                        Return SetError(4, 0, 0)                EndIf        Next         Return SetError(-1, 0, 0)EndFunc   ;==>_ObjectSHFolderViewFromWin ; ==========================================================================================================================; Func _ExplorerWinGetSelectedItems($hWnd);;; Author: klaus.s, KaFu, Ascend4nt (consolidation & cleanup, Path name simplification); ========================================================================================================================== Func _ExplorerWinGetSelectedItems($hWnd)        If Not IsHWnd($hWnd) Then Return SetError(1, 0, '')        Local $oSHFolderView        Local $iSelectedItems, $iCounter = 2, $aSelectedItems[2] = [0, ""]         $oSHFolderView = _ObjectSHFolderViewFromWin($hWnd)        If @error Then Return SetError(@error, 0, '')         ;   SelectedItems = FolderItems Collection object->Count        $iSelectedItems = $oSHFolderView.SelectedItems.Count         Dim $aSelectedItems[$iSelectedItems + 2] ; 2 extra -> 1 for count [0], 1 for Folder Path [1]         $aSelectedItems[0] = $iSelectedItems        ;   ShellFolderView->Folder->Self as 'FolderItem'->Path        $aSelectedItems[1] = $oSHFolderView.Folder.Self.Path         ;   ShellFolderView->SelectedItems = FolderItems Collection object        $oSelectedFolderItems = $oSHFolderView.SelectedItems         #cs                ; For ALL items in an Explorer Window (not just the selected ones):                $oSelectedFolderItems = $oSHFolderView.Folder.Items                ReDim $aSelectedItems[$oSelectedFolderItems.Count+2]        #ce         For $oFolderItem In $oSelectedFolderItems                $aSelectedItems[$iCounter] = $oFolderItem.Path                $iCounter += 1        Next         Return SetExtended($iCounter - 2, $aSelectedItems)EndFunc   ;==>_ExplorerWinGetSelectedItems Func _ComErrFunc($oError)        ConsoleWrite("COM Error occurred:" & @CRLF & _                        "Number: " & @TAB & $oError.number & @CRLF & _                        "Windescription:" & @TAB & $oError.windescription & @CRLF & _                        "Description is: " & @TAB & $oError.description & @CRLF & _                        "Source is: " & @TAB & $oError.source & @CRLF & _                        "Helpfile is: " & @TAB & $oError.helpfile & @CRLF & _                        "Helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _                        "Lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _                        "Scriptline is: " & @TAB & $oError.scriptline & @CRLF & _                        "Retcode is: " & @TAB & $oError.retcode & @CRLF & @CRLF)EndFunc   ;==>_ComErrFunc

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version