4

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?

opg
  • 35
  • 2

2 Answers2

2

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;
} 

HopelessN00b
  • 53,385
  • 32
  • 133
  • 208
  • 1
    Note: If you don't have any way to compile a C++ program I'd suggest [Visual Studio Express for Windows Desktop](http://www.visualstudio.com/en-us/products/visual-studio-express-vs.aspx) (free). – Chris S Jul 28 '14 at 13:51
-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.