|
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.
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
I've updated the code to include a dialog that allows you to change both the Modified and Created Date/Times:
Screenshot: http://www.oobaloo.co.uk/Touch/v2/Touch_v2.png
VS.NET Project: http://www.oobaloo.co.uk/Touch/v2/Touch_v2_src.zip
Installer: http://www.oobaloo.co.uk/Touch/v2/TouchSetup.msi
Once again, it's pretty bare at the moment and the code is pretty messy to say the least -- I was trying to get something functioning before I cleaned it all up.
If you use it it'd be great to hear from you.
--
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
|
|
|
|
|
Thanks.
|
|
|
|
|
Well, that depends on how limp their system is. It wouldn't help you with the time limited stuff I have done....
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
|