|
Hi Chris,
It runs great now! I am not a programmer, so I would not have been able to compile the code. Thanks for re-doing this.
While not sure how much time you still want to devote to the utility, I thought it would be useful to share some observations:
- after pressing 'Go' a interim alert box now comes up: "True", with OK choice.
- the path-box has a memory, nice but it is quite persistent: a previously used long pathname 'overrides' a shorter one in the same sequence (up-directory -> root)
- I had a crash once - probably because of too long pathnames? - when timestamping a directory with many sub-sub-directories
- Maybe add another checkbox for the option to set the specific timestamp as filled in (so not shifting an offset, but having the usual function for changing the date/time attribute). But that wasn't the initial purpose of the utility of course.
Well, thanks again,
greetings from the NL, Gert.
|
|
|
|
|
Yikes. That was pretty amateur. I've removed the debug code I left in I also put in a check for long file names that may help.
As to the other suggestions: They would be nice to do but unfortunately I just don't have the time
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
|
Hi Chris,
"I just don't have the time"
Well, it looks like you're using it to the max, 24/7?
But, of course. I'm already grateful that you expanded the utility.
A detail then: some indication when it is done?
Success with the project, I must have a closer look into the Beginner sections.
ciao,
Gert
modified on Thursday, July 16, 2009 6:10 AM
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
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:->
|
|
|
|
|
That's not what he means I dont think. What we need is similar to what exifer http://bppdocs.camner.net/html/exifer_info.htm[^]can do with pictures, add a specific amount of time to each file date, so when you're done they don't end up at all the exact date, but rather an offset of time ahead or behind what they originally were.
|
|
|
|
|
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
|
|
|
|
|
Hi,
I am looking for a method to change created date of file. Have you got an idea?
Thank you.
Nguyen Trung Thanh
|
|
|
|
|
////////////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;
}
|
|
|
|
|
void CTimeStampDlg::StampFile(LPCTSTR szFile)<br />
{<br />
TRACE1("File is \"%s\"\n", szFile);<br />
<br />
<br />
<br />
HANDLE hFile;<br />
FILETIME fCreate, fAccess, fWrite;<br />
SYSTEMTIME sCreate,sAccess,sWrite;<br />
<br />
m_FileTime.GetAsSystemTime(sCreate);<br />
m_FileTime.GetAsSystemTime(sAccess);<br />
m_FileTime.GetAsSystemTime(sWrite);<br />
<br />
SystemTimeToFileTime(&sCreate, &fCreate);<br />
SystemTimeToFileTime(&sAccess,&fAccess);<br />
SystemTimeToFileTime(&sWrite,&fWrite);<br />
<br />
LocalFileTimeToFileTime(&fCreate,&fCreate);<br />
LocalFileTimeToFileTime(&fAccess,&fAccess);<br />
LocalFileTimeToFileTime(&fWrite,&fWrite);<br />
<br />
hFile = CreateFile(szFile, GENERIC_READ|GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_DELETE,NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);<br />
BOOL bResult = SetFileTime(hFile,&fCreate, &fAccess, &fWrite);<br />
CloseHandle(hFile);<br />
<br />
}
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
|
|
|
|
|
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
|
|
|
|
|
Hi Chris,
how can I change the directory's date/time (not the files inside it)?
Bye.
Giuseppe
|
|
|
|
|
You need to do such as:
BOOL change_dir_timestamp(TCHAR* DirName,const FILETIME&ftCreationTime,const FILETIME&ftLastAccessTime, const FILETIME&ftLastWriteTime)
{
HANDLE hDir = CreateFile(
DirName,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ|FILE_SHARE_DELETE,NULL,OPEN_EXISTING,
FILE_FLAG_BACKUP_SEMANTICS,
NULL);
if (hDir ==INVALID_HANDLE_VALUE )
return FALSE;
BOOL retval = SetFileTime(
hDir, &ftCreationTime,&ftLastAccessTime,&ftLastWriteTime);
CloseHandle(hDir);
return retval;
}
ChinTse Wu[^.^]
|
|
|
|
|
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
|
|
|
|
|
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!
|
|
|
|
|
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...
|
|
|
|
|
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
|
|
|
|
|
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.
|
|
|
|
|
How embarrassing
cheers,
Chris Maunder
|
|
|
|
|
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?"
|
|
|
|
|
shhhhhhhh
|
|
|
|
|
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
|
|
|
|
|
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 !
|
|
|
|
|
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.
|
|
|
|
|