|

Introduction
Working with a team of programmers in different time zones can be fun, but it can also cause major problems when files from different time zones get mixed and matched. The latest update to a new version of a file may have a date earlier than someone elses old version, meaning it won't be recompiled, or, a new file may have a date later than others meaning DevStudio repeatedly wants to recompile everything.
The solution to this is:
- Get everyone to set their computer to the same time. This may work for some, but can be extremely inconvenient to others, or
- Re-stamp the time on your files before sending them off to your colleagues.
I chose the latter, which meant I had to come up with a way to restamp file times. Enter TimeStamp.
This is as basic a "Touch" program as you'll find. Just enter in the offset in days, hours and minutes (positive will push file times into the future, negative into the past), select your files, then hit "Go". Simple.
Each file selected (either a single file or a complete directory tree) has it's "Last Modified" time set to the current time plus the offset that you choose.
The program remembers the last offset you've set, the last 10 files and directories you've stamped, and it's last screen location.
Thanks to:
- Chris Losinger - Drop Edit
- Vladimir Kvashin, Girish Bharadwaj and Lars Klose - Directory picker class
- Davide Calibro - Flat buttons
| You must Sign In to use this message board. |
|
| | Msgs 1 to 25 of 36 (Total in Forum: 36) (Refresh) | FirstPrevNext |
|
 |
|
|
Hi Chris, thanks for your Timestamp source code (although I don't like the MFC in it). I had to combine a lot of foto's from two different digicam's and discovered that their timeline was corrupted as the two internal clocks of the camera's were out of sync. So I modified just one line in your Timestamp code to get the fs.m_mtime changed with the updown counter settings, set to the timelag between both clocks:
fs.m_mtime += CTimeSpan(m_nDays, m_nHours, m_nMins,0);
(see TimeStampDlg.cpp, line 443)
After that, your little program saved me a lot of work!
jeroen van dael, hilversum, the netherlands
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Y'know when you set the date/time in a digital camera and you're in a hurry and you think it's 12-hour time and it's really 24-hour time, so you set it 12 hours too early? Then you take a bunch of pics and they're all 12 hours early...
Timestamp is an exellent utility, but it can't set a time stamp relative to what it currently is. Does anyone know of a utility that will do this?
Much appreciated.
-Bob Blanchard
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
|
Seems easy... like you could get pretty close by setting your time clock [just prior] to the time that you want to set them at... get the timestamp changer ready and click at the right moment as you sit watching the GUI clock. That should get you within a second or so.
Chris:->
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
Funny, I just ran into the same problem myself - accidentally set the date on my camera to am when I meant pm ... actually the "fix" is real easy ... change line 443 of TimeStampDlg.cpp to:
fs.m_mtime = fs.m_mtime + CTimeSpan(m_nDays,m_nHours,m_nMins,0);
For a bit of context, here's what mine looks like now:
void CTimeStampDlg::StampFile(LPCTSTR szFile) { TRACE1("File is \"%s\"\n", szFile);
CFileStatus fs; if (CFile::GetStatus(szFile, fs)) { fs.m_mtime = fs.m_mtime + CTimeSpan(m_nDays,m_nHours,m_nMins,0); //fs.m_mtime = m_FileTime; CFile::SetStatus(szFile, fs); } }
Works beautifully
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Hi, I am looking for a method to change created date of file. Have you got an idea? Thank you.
Nguyen Trung Thanh
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
////////////I am a beginner~~~
BOOL ChangeFileTime(CString &strFileName ,SYSTEMTIME &sNewCreateDate,SYSTEMTIME &sNewCreateTime ,SYSTEMTIME &sNewAccessDate,SYSTEMTIME &sNewAccessTime ,SYSTEMTIME &sNewWriteDate ,SYSTEMTIME &sNewWriteTime ,BOOL bChangeCreateDate,BOOL bChangeCreateTime ,BOOL bChangeAccessDate,BOOL bChangeAccessTime ,BOOL bChangeWriteDate ,BOOL bChangeWriteTime ) {
HANDLE hFile; SYSTEMTIME sCreate,sAccess,sWrite; hFile = CreateFile(strFileName, GENERIC_READ|GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_DELETE,NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
//////////////源文件时间 GetFileTime(hFile,&fCreate,&fAccess,&fWrite);
FileTimeToLocalFileTime(&fCreate,&fCreate); FileTimeToLocalFileTime(&fAccess,&fAccess); FileTimeToLocalFileTime(&fWrite,&fWrite);
FileTimeToSystemTime(&fCreate,&sCreate); FileTimeToSystemTime(&fAccess,&sAccess); FileTimeToSystemTime(&fWrite,&sWrite); ///////////////////////////
if (bChangeCreateDate) { sCreate.wYear = sNewCreateDate.wYear; sCreate.wMonth = sNewCreateDate.wMonth; sCreate.wDay = sNewCreateDate.wDay; sCreate.wDayOfWeek = sNewCreateDate.wDayOfWeek; } if (bChangeCreateTime) { sCreate.wHour = sNewCreateTime.wHour; sCreate.wMinute = sNewCreateTime.wMinute; sCreate.wSecond = sNewCreateTime.wSecond; //sCreate.wMilliseconds = sNewCreateTime.wMilliseconds; }
if (bChangeAccessDate) { sAccess.wYear = sNewAccessDate.wYear; sAccess.wMonth = sNewAccessDate.wMonth; sAccess.wDay = sNewAccessDate.wDay; sAccess.wDayOfWeek = sNewAccessDate.wDayOfWeek; } if (bChangeAccessTime) { sAccess.wHour = sNewAccessTime.wHour; sAccess.wMinute = sNewAccessTime.wMinute; sAccess.wSecond = sNewAccessTime.wSecond; //sAccess.wMilliseconds = sNewAccessTime.wMilliseconds; }
if (bChangeWriteDate) { sWrite.wYear = sNewWriteDate.wYear; sWrite.wMonth = sNewWriteDate.wMonth; sWrite.wDay = sNewWriteDate.wDay; sWrite.wDayOfWeek = sNewWriteDate.wDayOfWeek; }
if (bChangeWriteTime) { sWrite.wHour = sNewWriteTime.wHour; sWrite.wMinute = sNewWriteTime.wMinute; sWrite.wSecond = sNewWriteTime.wSecond; //sWrite.wMilliseconds = sNewWriteTime.wMilliseconds; }
SystemTimeToFileTime(&sCreate, &fCreate); SystemTimeToFileTime(&sAccess,&fAccess); SystemTimeToFileTime(&sWrite,&fWrite);
LocalFileTimeToFileTime(&fCreate,&fCreate); LocalFileTimeToFileTime(&fAccess,&fAccess); LocalFileTimeToFileTime(&fWrite,&fWrite); BOOL bResult = SetFileTime(hFile , (dwdateResult1 == GDT_VALID)?&fCreate:(dwtimeResult1 == GDT_VALID)?&fCreate:(LPFILETIME)NULL , (dwdateResult2 == GDT_VALID)?&fAccess:(dwtimeResult2 == GDT_VALID)?&fAccess:(LPFILETIME)NULL , (dwdateResult3 == GDT_VALID)?&fWrite:(dwtimeResult3 == GDT_VALID)?&fWrite:(LPFILETIME)NULL ); //SetFileTime(hFile,&fCreate, &fAccess, &fWrite);
CloseHandle(hFile); return bResult; }
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
void CTimeStampDlg::StampFile(LPCTSTR szFile) { TRACE1("File is \"%s\"\n", szFile);
/*CFileStatus fs; if (CFile::GetStatus(szFile, fs)) { fs.m_mtime = m_FileTime; CFile::SetStatus(szFile, fs); }*/
HANDLE hFile; FILETIME fCreate, fAccess, fWrite; SYSTEMTIME sCreate,sAccess,sWrite; m_FileTime.GetAsSystemTime(sCreate); m_FileTime.GetAsSystemTime(sAccess); m_FileTime.GetAsSystemTime(sWrite);
SystemTimeToFileTime(&sCreate, &fCreate); SystemTimeToFileTime(&sAccess,&fAccess); SystemTimeToFileTime(&sWrite,&fWrite);
LocalFileTimeToFileTime(&fCreate,&fCreate); LocalFileTimeToFileTime(&fAccess,&fAccess); LocalFileTimeToFileTime(&fWrite,&fWrite);
hFile = CreateFile(szFile, GENERIC_READ|GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_DELETE,NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); BOOL bResult = SetFileTime(hFile,&fCreate, &fAccess, &fWrite); CloseHandle(hFile);
//ChangeFileTime(szFile, m_FileTime.Get, m_FileTime, m_FileTime, m_FileTime, m_FileTime, m_FileTime, true, true, true, true, true, true); }
above is what i did to change created date in StampFile function
-------------------------- ERP VN: www.erpvn.net
-- modified at 22:43 Thursday 8th December, 2005
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Hi Guys,
Do you know if the use of timestamp can be scripted and if so, can u script the use of a unc path to run timestamp against?? This will be for use for a directory and all the files and folders below it. And can the tool modify/touch read only files? Or do i have to run attrib prior to timestamp to get rid of the readonly bit of the files.
Thanks Dazza
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
But it shows the poorness of the design of the full time stamp system - that I think inherited from DOS... Timestamps on files should be GMT times, converted to local time only when the they need to be displayed.
And your tool should be unnecessary...
Alas, thank you for it!
Pierre Couderc
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Not sure if this has been mentioned before...
There is an excellent Shell Extension available for Win95/98/nt4/2k/xp, called "Properties Plus 1.65", available at http://www.ne.jp/asahi/cool/kish/pplusmain.htm.
PropertiesPlus is a free add-on for your Windows Explorer.
It adds additional functionality to your right-click menu under the menu option PropertiesPlus.
Here you'll be able to modify file attributes, file extensions, and the time stamps of single files, multiple files, or files contained within the folders. Display the bytes allocated.
Give it a look, been using it for quite a long time, it's one of those system programs that I always install on a new system, it's just that handy!
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Well, while we are on the topic of favorite closed source freewares, for this purpose, I use Date/Time Shell Extension, that can be found at http://space.dolphin.free.fr/Windows/main.html It has numerous options, can change Creation and Modified time/date, etc.
Check out also his Folder Size Shell Extension...
Well, if you look around, you can also find other freewares for this purpose. Now, Chris' approach is original because it uses a time offset, not an absolute one. And we get the source...
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Gurus, Let me preface this by saying that I'm not a programmer. I was doing a search to find the tools available to change the timestamp on a file/folder.....
My question is, "Is it possible to tell if a file has had its timestamp tampered, perhaps by using one of the available utilities?" This question is asked from a security point of view.
thanks
Kirk
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
I didn't see this article until after I submitted my own article.
At least my article (http://www.codeproject.com/useritems/touch_win.asp[^]) is a command line tool, so there is at least some difference.
But it really feels like going to a party, to find out you've dressed just like someone else at that party. Can I go home now?
-- If I had the ability to smooth talk like John Simmons, this post would be less sarcastic and more to the point.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
If your users reported a problem in your server program to your manager, you can fixed it quickly (as quickly as Chris Maunder ) and redeploy it after setting the timestamp to that of the previous version. Then you can say to your manager "Problem? What problem?" 
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
Ok, so the challenge is now to put it into a Shell Extension
-- Paul "If you can keep your head when all around you have lost theirs, then you probably haven't understood the seriousness of the situation." - David Brent, from "The Office"
MS Messenger: paul@oobaloo.co.uk Sonork: 100.22446
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Paul Ingles wrote: Ok, so the challenge is now to put it into a Shell Extension
You know in Windows Media Player you can select a bunch of songs, right click and click Edit. Then whatever you type gets entered into the selected field for all of the files. Very handy that (Explorer has it too, but only for the Filename field.)
Nice to have that for the Date field
Paul Watson Bluegrass Cape Town, South Africa Colin Davies wrote: ...can you imagine a John Simmons stalker !
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
You may try Michael Dunn's The Complete Idiot's Guide to Writing Shell Extensions - Part V[^].
It's surprising how many goodies can be found at CodeProject
Regards Thomas
Sonork id: 100.10453 Thömmi
Disclaimer: Because of heavy processing requirements, we are currently using some of your unused brain capacity for backup processing. Please ignore any hallucinations, voices or unusual dreams you may experience. Please avoid concentration-intensive tasks until further notice. Thank you.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
I had spotted that actually, I was going thinking about modifying Chris' code to a shell extension and went straight to Mike's articles. Anyway, I'm still going to give it a go -- I've not done any ATL programming for an extremely long time.
-- Paul "If you can keep your head when all around you have lost theirs, then you probably haven't understood the seriousness of the situation." - David Brent, from "The Office"
MS Messenger: paul@oobaloo.co.uk Sonork: 100.22446
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
I've converted the (very) basic functionality of touch into a shell extension. It's extremely simple at the moment, so it doesn't warrant a CodeProject article -- effectively just calls a Win32 API function to set the file's time to now.
Anyway, I've put up the source code on my website, along with a Windows Installer package.
http://www.oobaloo.co.uk/Touch/Touch_src.zip[^] http://www.oobaloo.co.uk/Touch/TouchSetup.msi[^]
When you right click on a file or selection of files, a new option will appear.
I've got to get on with some proper University work now (shouldn't have done this really ), but I'll try and get around to implementing the same functionality as Chris' utility when I get a chance.
-- Paul "If you can keep your head when all around you have lost theirs, then you probably haven't understood the seriousness of the situation." - David Brent, from "The Office"
MS Messenger: paul@oobaloo.co.uk Sonork: 100.22446
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
 |
|
|
General News Question Answer Joke Rant Admin
|