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

DonationCoder.com Software > Finished Programs

DONE: Tally folder contents by file date

(1/4) > >>

nkormanik:
Suppose we have a folder with 100 files.

Objective is to create a text file with a list of dates and tally of those dates based on the 100 files.

Example:

2018-09-22 7
2018-09-19 8
2018-09-14 11
...
2018-09-3 1

Space separator between date and tally number.

No spaces within date.

Result can be sorted, or not.  Preference is to sort by date.

File name output should be same as folder name.  Plus .txt.

No need for GUI.  Command-line preferred, for creation of batch files (say, acting on lots of different folders).

Resultant .txt file should be created in same folder as executable, wherever user wants to keep that.

Parameter after executable should be folder path where files reside.

Example:

Tally_by_date.exe "C:\Program Files\My Program 123"

Use of piping might be okay.

Example:

Tally_by_date.exe "C:\Program Files\My Program 123" >> "My Program 123"

Any help greatly appreciated.

Thanks!

Nicholas Kormanik

wraith808:
And by date, do you mean cration date of the files, modification date, or something else?

nkormanik:
Creation date.

Thanks for asking!

wraith808:
You can download it from https://my.pcloud.com/publink/show?code=XZJdFe7ZIMrABuCLAxYJFJUz9dOpvmb4fLby

There are two files in the 75kb archive... TallyFiles.exe and CommandLine.dll.

Run TallyFiles to see the options, but they are

        [Option('d', "directory", Required = true, HelpText = "Directory to Scan")]
        [Option('f', "format", Required = false, HelpText = "Format of Date (Default yyyy-MM-dd)")]
        [Option('o', "output", Required = false, HelpText = "output filename (default name of directory, stored in directory)")]
        [Option('c', "compare", Required = false, HelpText = "compare to [C]reation Date or Last [A]ccess Date or Last [W]rite Date")]


So by default, if you run TallyFiles d=c:\test it will tally the files in c:\test and store them in c:\test\text.txt.  Formats are c# datetime formats (https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings), and if you specify an output filename, it will store it there. 

Requires .NET 4.5.2

Let me know if you have any questions.

Update: Added ability to use write and last access dates.



Nod5:
I could use something like that too so here is an alternative implementation in AutoHotkey


--- Code: Autohotkey ---#NoEnv#SingleInstance force ;Tally_by_date.ahk;by nod5 ;- compile it and run from the command line with a folder path as parameter;- outputs a date sorted tally of date created for all files in the input folder ; example input: tally_by_date.exe "C:\this folder\folder" ; example output: C:\this folder\folder\Tally_by_date -- 201809220631.txt; with the content:; 2018-07-23 9; 2018-08-03 4; ... folder := A_Args[1] if !InStr( FileExist(folder), "D")  ;not folder  exitapp f_array := [] ;loop over all files in folder, exclude folders and do not recurseLoop, Files, % folder "\*.*"{  ;get date in YYYY-MM-DD format  FormatTime, date_var, % A_LoopFileTimeCreated, yyyy-MM-dd  f_array[date_var] := f_array[date_var] ? f_array[date_var] + 1 : 1}For key, val in f_array  out .= key " " val "`n" FileAppend, % out , % folder "\Tally_by_date -- " A_now ".txt"

Navigation

[0] Message Index

[#] Next page

Go to full version