|
your tool saved me from the reorganisation of my whole project. after modifying the timestamps of all file to the current, VS will deploy it again.
|
|
|
|
|
Great!
cheers,
Chris Maunder
The Code Project | Co-founder
Microsoft C++ MVP
|
|
|
|
|
... I was just about to code myself.
How good that I had a thorough look here first! Thank you!
It saved my day when trying to re-date dozens and dozens of video files from my digicam (no exif like in the digipics, where there exist many of these tools).
Great job!
-LZ
|
|
|
|
|
This utility has been a gigantic help as I sort through mounds of photos from two different camera with janky timestamps. Much appreciated.
|
|
|
|
|
Nice article.
I collected the source and attempted to compile, and there were a couple
of errors. Seems "USES_CONVERSION" and T2COLE were not found.
After adding the following line to stdafx.h all is well.
#include <afxpriv.h>
Thanks
Brian
|
|
|
|
|
Hi Chris,
Would it be a great effort for you to produce another little utility that takes the original data/time value from a file and rewrites an offset to it, just like it is done with your Timestamp utility (that uses the current time). It would be quite useful to correct timestamps to sets of files.
Thanks a lot,
Gert
|
|
|
|
|
Try it now
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
|
Thanks Chris for such a quick reply and action.
Unfortunately the utility does not run because "the application has failed to start because the configuration is incorrect"
I downloaded the zip file from the page, I notice that it indeed had changed. Can you guess what's wrong?
Will the timestamp of the (sub)directories also be adjusted?
Thanks,
Gert
|
|
|
|
|
Sounds like you have a version of windows that has the older C++ libs. I've uploaded a new version that is statically linked. If that doesn't work then the best bet is to recompile it on your system.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
|
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!
|
|
|
|
|