How to customize the creation time (ctime)?

Hey,

I use Haiku OS nighlty version (hrev55092). In the list view, I can expand the column with a right mouse click and then Tracker shows “Created” for my directories and files in addition to “Modified”. By default only “Modified” is displayed.

Under Get Info “Created” and “Modified” is shown, by default.

But I have not found a direct way in Tracker to change the “Created” and “Modified” timestamps.

Is there this function in Tracker, if not can it be added?

Still another question is there a command for Terminal to manually change “Created” and “Modified”? It would be good if I can change year, month, day, hour, minute and second.

  1. Default view Default view
  1. Modified and Created
    Modified and Created

Welcome aromaticmoongladesea!

From my quick web search, ctime is generally not supposed to be modifiable.
There’s a work-around though, explained at

And you can use touch for manually changing the last modified date/time.

I also needed to modify ctime a while ago and wrote the following setcreatetime.cpp:

#include <stdio.h>
#include <time.h>
#include <Entry.h>

int main(int argc, char* argv[])
{
	BEntry* entry;

    int year, month, day, hour, min, sec;
	
	if(argc != 3)
	{
		printf("Usage: setcreatetime [filename] [Date/Time in format YYYY:MM:DD MI:HH:SS]\n");
		return 0;
	}

   if(sscanf(argv[2], "%4d:%2d:%2d %2d:%2d:%2d", &year, &month, &day, &hour, &min, &sec) != 6)
   {
		printf("Invalid date/time format\n");
		return -1;	
   }
    struct tm newTime = {0};
    newTime.tm_year = year - 1900;
    newTime.tm_mon = month - 1;
    newTime.tm_mday = day;
    newTime.tm_hour = hour;
    newTime.tm_min = min;
    newTime.tm_sec = sec;

	entry = new BEntry(argv[1]);
    entry->SetCreationTime(mktime(&newTime));
}

@Jim

There is a report in bug tracker where people wish it to be added to Tracker.
https://dev.haiku-os.org/ticket/16948

Can you add it to Tracker or create a third party tools for users?