Creating a folder named using date from file under cursor?

English support forum

Moderators: Hacker, petermad, Stefan2, white

Post Reply
sybariten
Junior Member
Junior Member
Posts: 79
Joined: 2003-05-29, 17:31 UTC

Creating a folder named using date from file under cursor?

Post by *sybariten »

Hello!

The default behaviour of TC when pressing F7 (over a directory) is that the new folder will be suggested the same name as the one where you're standing, which is great.

I am starting, these days, to put my photographs into folders that have a date string first: "20150322_car_expo"

Since i start from a folder/SD-card of many photographs that will be split into multiple folders, it would be nice to be able to create the dirnames quickly and get the date without needing to read the date string manually.

Could some function be made, that when executed, will give me a dirname requester just like with F7 but it will take the creation/modification date from the file under cursor and wait for me to fill in the rest?

If its complicated to create something that waits, i suppose i could make the folder completely first with just the date string in the name, and then rename it with F2.

(Yes, i'm lazy and always looking for ways to optimize processes)

cheers
User avatar
Dalai
Power Member
Power Member
Posts: 10035
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Post by *Dalai »

I don't know if it helps, but you can take a look at the extDir tool.

Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
RedTiF
Junior Member
Junior Member
Posts: 19
Joined: 2009-09-10, 11:03 UTC

Post by *RedTiF »

Hi sybariten,

I'm working with this command:
em_ext_newdir

"Make directory with same name as file under cursor in opposite panel"

Will this solve your problem?

Rgds RedTiF
User avatar
ts4242
Power Member
Power Member
Posts: 2081
Joined: 2004-02-02, 20:08 UTC
Contact:

Post by *ts4242 »

RedTiF wrote:Hi sybariten,

I'm working with this command:
em_ext_newdir

"Make directory with same name as file under cursor in opposite panel"

Will this solve your problem?

Rgds RedTiF
This command isn't one of TC internal command, but it is part of petermad's Extended Total Commander Menus
User avatar
nsp
Power Member
Power Member
Posts: 1953
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Re: Creating a folder named using date from file under curso

Post by *nsp »

sybariten wrote:Hello!

The default behaviour of TC when pressing F7 (over a directory) is that the new folder will be suggested the same name as the one where you're standing, which is great.

I am starting, these days, to put my photographs into folders that have a date string first: "20150322_car_expo"

Since i start from a folder/SD-card of many photographs that will be split into multiple folders, it would be nice to be able to create the dirnames quickly and get the date without needing to read the date string manually.

Could some function be made, that when executed, will give me a dirname requester just like with F7 but it will take the creation/modification date from the file under cursor and wait for me to fill in the rest?

If its complicated to create something that waits, i suppose i could make the folder completely first with just the date string in the name, and then rename it with F2.

(Yes, i'm lazy and always looking for ways to optimize processes)

cheers
If you do not need unicode, you can use TCBL with a command inside TCBL.ini

Code: Select all

command:<pathTo\tcbl.exe
parameters: -i %L FolderWithFileDate %T>
and the TCBL script

Code: Select all

[FolderWithFileDate]
;Request the same folder name suffix for all files at once  	
ini=1 Directory Name	YYYYMMDD_<Name>	Folder
;no automatic quote
ini=q
;Date format for file %Y year %m month  %d day => YYYYMMDD 
ini=# %Y%m%d
pre=@echo off
; create folder using first parameter %T from TC
;  add creation time $c
;  add internal variable 1
cmd=echo use file $n $#c $#m $#a  to create  "$#c_$_1"
cmd=set FolderNAME=$1\$#c_$_1
cmd=md "%FolderNAME%"
;;; copy file to folder  (optionnal )
cmd=copy "$f" "%FolderNAME%\$n"
If you want to get a suffix for each file, you can use askparam or edit the batch before execution. using -e option

-- edited to add copy of file
Last edited by nsp on 2015-06-05, 12:19 UTC, edited 1 time in total.
User avatar
Stefan2
Power Member
Power Member
Posts: 4281
Joined: 2007-09-13, 22:20 UTC
Location: Europa

AHK script: Create folder name date file under cursor?

Post by *Stefan2 »

sybariten wrote:I am starting, these days, to put my photographs into folders
that have a date string first: "20150322_car_expo"

Since i start from a folder/SD-card of many photographs that will be split into multiple folders,
it would be nice to be able to create the dirnames quickly
and get the date without needing to read the date string manually.

Could some function be made, that when executed, will give me a dirname requester just like with F7
but it will take the creation/modification date from the file under cursor
and wait for me to fill in the rest?
Here is a AutoHotkey script for your issue:

;// 1. Select one file.
;// 2. Execute this script to read file date and prompt you to create a new folder.
;// 3. Folder will be created with name, taken form file date [file will be moved to new folder]

Code: Select all

;===================================================================================== Description
;// http://ghisler.ch/board/viewtopic.php?p=296756&sid=8c4d126bf1aee4f7a090d16fbac1ca43#296756
;// sybariten PostPosted: Thu Jun 04, 2015 15:18   
;// Creating a folder named using date from file under cursor?
;// Could some function be made, that when executed, will give me a dirname requester just like with F7 
;// but it will take the creation/modification date from the file under cursor and wait for me to fill in the rest? 
;// Example: "20150322_car_expo" 
;//
;// Needs http://ahkscript.org/download/1.0/AutoHotkey104805.zip
;//
;// TC Command
;// Command: path\to\AutoHotkey.exe path\to\ThisScript.ahk
;// Parameter: 
;// Start path: 
;// Icon file: path\to\AutoHotkey.exe
;// Tooltip: Create folder from date of selected file, move file to new folder
;// 
;// 1. Select one file.
;// 2. Execute this script to read file date and prompt you to create a new folder.
;// 3. Folder will be created with name, taken form file date [file will be moved to new folder]

;===================================================================================== AHK Basics
;//  S C R I P T    S E T T I N G S:
#SingleInstance force  ;Skips the dialog box and replaces the old instance automatically
;#NoTrayIcon           ;if you don't want a tray icon for this AutoHotkey program.
#NoEnv                 ;Recommended for performance and compatibility with future AutoHotkey releases.
;===
;This script information:
strAppName = CreateFolderMoveFile
strVersion = 0.01
strVerDate = 2015-06-05
;===
;// TC related stuff
;//Check if running under Total Commander:
If not WinActive("ahk_class TTOTAL_CMD") {
    MsgBox Please execute this application from within Total Commander.
    ExitApp
}  
;//Get TC handle:
WinGet, vTCHandleID, ID, A
ControlGetFocus, vCurrFocus, ahk_id %vTCHandleID%

;===================================================================================== AHK Script code
;//   T H E    C O D E:

;//Store current clipboard content:
    vClipboardStorage := clipboard

;//Execute TC-command:
    ;//TOTALCMD.INC: cm_CopyNamesToClip=2017;Copy filenames to clipboard
    ;//SendMessage, 0x0433, <command ID here>, , , ahk_id%vTCHandleID%
    SendMessage, 0x0433, 2017, , , ahk_id%vTCHandleID%

;// GET CLIPBOARD CONTENT:
    vMySelectedFile := clipboard
    ;msgbox % vMySelectedFile

;//Check if more than one file was selected:
    ;//IfInString, var, SearchString
    IfInString, vMySelectedFile, `r`n
    {
        MsgBox To many files. Please select one single file only. Script quits here.
        ExitApp
    }

;//sybariten wrote: but it will take the creation/modification date from the file under cursor ...
;//Get the date from the file meta data
    ;//FileGetTime, OutputVar [, Filename, WhichTime]
    ;//Which timestamp to retrieve:
    ;//M = Modification time (this is the default if the parameter is omitted)
    ;//C = Creation time        ;//A = Last access time 
    FileGetTime, vMyFileDate , %vMySelectedFile%, M

;//Format the date to a wanted format:
    ;//FormatTime, OutputVar [, YYYYMMDDHH24MISS, Format]
    ;//Or here just the first 8 signs
    ;//sybariten wrote:  Example: "20150322_car_expo" 
    ;//StringLeft, OutputVar, InputVar, Count
    StringLeft, vMyFileDate, vMyFileDate, 8

;//Create a new folder, if not already exist:
    ;//If var is [not] type
    If vMyFileDate is time 
    {

        ;//sybariten wrote: and wait for me to fill in the rest? ;// Example: "20150322_car_expo" 
        ;//InputBox, OutputVar [, Title, Prompt, HIDE, Width, Height, X, Y, Font, Timeout, Default]
        InputBox, vMyFolderName , Total Commander, New folder (directory), , ,130 , , , , , %vMyFileDate%_
        if ErrorLevel 
            ExitApp
        else
        {
            ;FileCreateDir, DirName
            FileCreateDir, %vMyFolderName%
        }
    }
    
;//Move the file into the newly created folder:
    ;//FileMove, SourcePattern, DestPattern [, Flag]
    ;FileMove, %vMySelectedFile%, %vMyFolderName%

;Restore last clipboard content:
    clipboard := vClipboardStorage 
    
ExitApp
;//DONE <EOF>

HTH? :)
User avatar
solid
Power Member
Power Member
Posts: 755
Joined: 2004-08-09, 11:20 UTC

Post by *solid »

Also check the mover plugin. It's rather old but performs well.

It automatically creates folders with year/month/date names of the selected files and moves the files accordingly into them.
sybariten
Junior Member
Junior Member
Posts: 79
Joined: 2003-05-29, 17:31 UTC

Post by *sybariten »

Wow! Thanks for the great response and all the good suggestions in this thread!
I haven't had time to try them yet, but they made me learn about some helper progams that i didn't know. I'll get back with results.
User avatar
Hacker
Moderator
Moderator
Posts: 13144
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

sybariten,
Here is another AutoHotkey script, which you can assign to eg. Shift-F7 by creating a user command.

Code: Select all

ClipboardBak = %ClipboardAll%
Clipboard =
PostMessage, 1075, 2018, , , A
ClipWait
FileGetTime, TimeStamp, %Clipboard%
PostMessage, 1075, 907, , , A
Clipboard = %ClipboardBak%
FormatTime, TimeStamp, %TimeStamp%, yyyyMMdd
WinWaitActive, Total Commander ahk_class TCOMBOINPUT
SendInput, %TimeStamp%
HTH
Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
User avatar
Stefan2
Power Member
Power Member
Posts: 4281
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Post by *Stefan2 »

[face=timesnewroman]PostMessage 907, SendInput[/face] 8) clever :D





 
Post Reply