3

We've archived old (more than 2 year old) files on our fileserver using FSRM to a different directory by moving and replacing the files with symlinks - the problem is that the symlinks have as a filedate the date the script ran - nothing to do with the original filedate. Users are not happy that half their files have the same date - is it possible to either modify the date of the symlinks to be the same as the one of the original files, or recreate them from scratch with the right date? Anyone encountered this issue when archiving with FSRM?

1

It seems like it is possible, but far from easy. Brace yourself... I know of no utility that will do this, but someone punched up some code that appears to work.


DWORD SetSymLinkTimesW(const wchar_t *filename, const FILETIME *ftc,
const FILETIME *fta, const FILETIME *ftw)
{
   DWORD            ret;
   HANDLE           h;

   h = CreateFileW(filename, GENERIC_READ | GENERIC_WRITE,
                               FILE_SHARE_READ | FILE_SHARE_WRITE,
                               NULL, OPEN_EXISTING,
                               FILE_FLAG_OPEN_REPARSE_POINT, NULL);
  if(h != INVALID_HANDLE_VALUE)
  {
     if(SetFileTime(h, ftc, fta, ftw) == TRUE)
    {
     CloseHandle(h);
     ret = NO_ERROR;
    }
    else
    {
      ret = GetLastError();
      CloseHandle(h);
    }
  }
  else
   ret = GetLastError();
  return ret;
} 

I've just copied and pasted your code into a console application and
it successfully changes the timestamps of a symlink for me (Win8.1
32-bit).

int _tmain(int argc, _TCHAR* argv[])
{
        FILETIME ft;

        GetSystemTimeAsFileTime( &ft );
        SetSymLinkTimesW( argv[1], &ft, &ft, &ft );
        return 0;
} 

| improve this answer | |
-1

DirDate v6.3 now implements this - http://www.datamystic.com/dirdate2.exe

Change the date and time of symbolic links (symlinks) otherwise known as file reparse points.

| improve this answer | |
  • Don't trust executables from spammers. – Arjan Oct 30 '16 at 20:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.