Click here to Skip to main content
Licence CPOL
First Posted 26 Nov 2002
Views 213,184
Downloads 5,573
Bookmarked 70 times

Timestamp - A utility to change a files "Modified" time.

By | 15 Jul 2009 | Article
A simple utility to change a file - or multiple files - "Modified" time.

timestamp.png

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:

  1. Get everyone to set their computer to the same time. This may work for some, but can be extremely inconvenient to others, or
  2. 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

History

  • 15 July 2009 - Added ability to set file times relative to the original file's time. Also compiles in VC9.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Chris Maunder

Founder
The Code Project
Canada Canada

Member

Follow on Twitter Follow on Twitter
Google+
Chris is the Co-founder, Administrator, Architect, Chief Editor and Shameless Hack who wrote and runs The Code Project. He's been programming since 1988 while pretending to be, in various guises, an astrophysicist, mathematician, physicist, hydrologist, geomorphologist, defence intelligence researcher and then, when all that got a bit rough on the nerves, a web developer. He is a Microsoft Visual C++ MVP both globally and for Canada locally.
 
His programming experience includes C/C++, C#, SQL, MFC, ASP, ASP.NET, and far, far too much FORTRAN. He has worked on PocketPCs, AIX mainframes, Sun workstations, and a CRAY YMP C90 behemoth but finds notebooks take up less desk space.
 
He dodges, he weaves, and he never gets enough sleep. He is kind to small animals.
 
Chris was born and bred in Australia but splits his time between Toronto and Melbourne, depending on the weather. For relaxation he is into road cycling, snowboarding, rock climbing, and storm chasing.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralThis is exactly the tool... PinmemberLastZolex1:02 11 Mar '10  
GeneralJust sayin' thanks Pinmemberpaul curthoys13:19 28 Dec '09  
GeneralMissing afxpriv.h PinmemberBrianCharles8:45 20 Jul '09  
Generaloffset the timestamp using original value ... PinmemberGert3d2:34 15 Jul '09  
GeneralRe: offset the timestamp using original value ... PinadminChris Maunder3:32 15 Jul '09  
GeneralRe: offset the timestamp using original value ... PinmemberGert3d4:02 15 Jul '09  
GeneralRe: offset the timestamp using original value ... PinadminChris Maunder4:49 15 Jul '09  
GeneralRe: offset the timestamp using original value ... PinmemberGert3d21:28 15 Jul '09  
GeneralRe: offset the timestamp using original value ... PinadminChris Maunder21:51 15 Jul '09  
GeneralRe: offset the timestamp using original value ... [modified] PinmemberGert3d23:41 15 Jul '09  
GeneralUse modified Timestamp for foto-file synchronization Pinmemberjeroen van dael2:12 12 Dec '06  
QuestionAdd 12 hours to *existing* time stamp? Pinmemberrcblanchard3:55 26 Dec '04  
AnswerRe: Add 12 hours to *existing* time stamp? PinmemberThe Chrisman8:02 27 Feb '06  
GeneralRe: Add 12 hours to *existing* time stamp? Pinmemberkwestman6:31 11 Jul '06  
GeneralRe: Add 12 hours to *existing* time stamp? PinmemberPsinewave15:53 20 Aug '06  
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 Smile | :)
Questionchange created date of file? Pinmemberngtrungthanh2:12 14 Apr '04  
AnswerRe: change created date of file? Pinmemberifbn18:05 31 Aug '04  
GeneralRe: change created date of file? Pinmembermeouvn16:42 8 Dec '05  
Generaltimestamp Pinmemberdazzavazza3:09 27 Mar '03  
Generaldirectory's date/time PinmemberPeppe23:06 11 Dec '02  
GeneralRe: directory's date/time Pinmemberwct17:48 12 Oct '10  
GeneralAlas useful... PinmemberPierre Couderc6:54 3 Dec '02  
GeneralYou can do this already with an excellent Shell Extension - PropertiesPlus 1.65 Pinmemberme10112:50 2 Dec '02  
GeneralRe: You can do this already with an excellent Shell Extension - PropertiesPlus 1.65 PinmemberPhilippe Lhoste22:31 2 Dec '02  
GeneralRe: You can do this already with an excellent Shell Extension - PropertiesPlus 1.65 Pinsusskajjo13:00 3 Aug '03  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120529.1 | Last Updated 15 Jul 2009
Article Copyright 2002 by Chris Maunder
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid