Solved

Batch operation to make file creation date equal to file modification date

Posted on 2013-11-22
26
1,519 Views
Last Modified: 2013-12-10
Running Windows 7 Professional, I recently installed an Outlook Add-in called NEO Find.  When that program created a catalog for indexing, it appears to have set the file modified date of thousands of my archived .eml files to the present date.  The software vendors are skeptical that their application caused this, because NEO Find indexes Outlook pst files, not Outlook Express .eml files.   However, the file modified date of every .eml file was changed to the date and time when NEO Find was installed.  In any case, I've used an application called Total Commander to restore the file modified dates to all those .eml files, based on a backup.  However, Total Commander doesn't change the file creation date.  I'm looking for a way to perform a batch operation which sets the file creation date equal to the file modified date on all .eml files.
0
Comment
Question by:ddantes
  • 12
  • 8
  • 5
26 Comments
 
LVL 14

Expert Comment

by:Giovanni Heward
Comment Utility
Take a look at timestomp, which uses the following Windows system calls:

NtQueryInformationFile()
NtSetInformationFile()

Timestomp MACE value change
Here's a quick one liner:

for /f "delims=" %f in ('dir *.eml /a-d/b/s 2^>nul') do timestomp "%f" -m "Monday 01/01/2001 01:01:01 AM"

Open in new window


See http://www.blackhat.com/presentations/bh-usa-05/bh-us-05-foster-liu-update.pdf
0
 

Author Comment

by:ddantes
Comment Utility
Thank you for your comment.  I downloaded timestompGUI.exe, but it doesn't appear to have the command line interface which is required for a batch operation.   The link  to Timestomp.exe on the page which your link referenced is a dead link.  Is there another version of Timestomp which I should download?
0
 
LVL 14

Expert Comment

by:Giovanni Heward
Comment Utility
I did notice that after my post and modified the link above to reflect a location hosting the file. ( http://www.jonrajewski.com/resources/ )

If you want to dig in and are familiar with AutoIt, see SetMACE as well, which is an improvement upon timestomp.
0
 

Author Comment

by:ddantes
Comment Utility
Thank you.  OK, now I can open the command window for Timestomp.   I'm not sure how to apply your "one liner."    Just to be sure I've communicated the intended outcome...  I have thousands of .eml files in different subdirectories, but on the same drive letter.  These .eml files have differing, but accurate modified date stamps.  Their date created stamps are inaccurate, all reading today's date.  I'm wanting the file created date changed to match the file modified date.
0
 
LVL 51

Accepted Solution

by:
Joe Winograd, EE MVE earned 400 total points
Comment Utility
Hi ddantes,

I recommend DataMystic's DirDate:
http://www.datamystic.com/dirdate.html

The command line syntax is:

dirdate [options] [date parts] <filespec>

Here's how/why the parameters should be set up:

o  Since you have thousands of files in different subdirectories, you'll need "-R" (Recurse into subdirectories) in the [options].

o  I'm presuming you want to do this just on the EML files, so the <filespec> should be <D:\start_dir\*.eml>. If not, just change the wildcard to be whatever you want (and, of course, set the drive letter and starting directory path as needed).

o  You want to change the CREATED date, so you'll need "CREATED=" in the [options].

o  On each file, you want to change its CREATED date to its current MODIFIED date, so you'll need "current_modified" in the [date parts].

Adding all this up, here's the command you need:

dirdate -r created= current_modified d:\start_dir\*.eml

(There's a space between the equal sign and current_modified.)

Also, I've attached the full syntax for you in a PDF file, in case you want to see the other capabilities that it has. It is an extraordinarily powerful utility for dealing with file and folder dates. They offer a full-featured, 30-day free trial, so you can see if it works well for you before buying it.

Btw, that testimonial from me on the site is, indeed, exactly what I said, but as a disclaimer, I want to emphasize that I have no affiliation with this company and no financial interest in it whatsoever. I am simply a happy user/customer (and I paid for the software). Regards, Joe
DirDate-command-line-syntax.pdf
0
 

Author Comment

by:ddantes
Comment Utility
Thank you for your thorough instructions.  I downloaded the trial version of DirDate and performed the following command line operation:
dirdate -r created= current_modified V:\My Documents\Archived Documents\HCA\Email\*.eml

This would test the application on .eml files located in that particular subfolder.

The operation appeared to complete (see screenshot) but the .eml file creation dates in that subfolder have not changed.  Please advise.DirDate command window
0
 
LVL 51

Expert Comment

by:Joe Winograd, EE MVE
Comment Utility
I tested it here...worked perfectly. Please do a right-click on one of the files, then Properties. Are the Created and Modified dates not the same now?
0
 
LVL 51

Expert Comment

by:Joe Winograd, EE MVE
Comment Utility
Oh, I think it's the spaces in your filespec. Put quotes around it, i.e.:
"V:\My Documents..." (beginning and ending quotes).
0
 

Author Comment

by:ddantes
Comment Utility
The file creation date for all my .eml files was inadvertently set to Jan. 3, 2013, the date when a certain file operation was performed.  After running DirDate, I don't see any difference (See screenshot of properties of one file in the target directory).
File properties after running DirDate
0
 
LVL 51

Expert Comment

by:Joe Winograd, EE MVE
Comment Utility
Our messages just crossed. I'm pretty sure the problem is the quotes around your filespec...DirDate is not being passed the correct folder name due to the spaces in the parameter.
0
 

Author Comment

by:ddantes
Comment Utility
Yes!  That did it.  Thank you for your help.
0
 

Author Comment

by:ddantes
Comment Utility
Awesome solution!
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 51

Expert Comment

by:Joe Winograd, EE MVE
Comment Utility
Excellent! You're very welcome.
0
 

Author Comment

by:ddantes
Comment Utility
Thanks to both Experts who contributed.
0
 
LVL 14

Assisted Solution

by:Giovanni Heward
Giovanni Heward earned 100 total points
Comment Utility
Sorry for the delay, here's the batch script which will work with timestomp.

@echo off
setlocal enabledelayedexpansion
set ext=eml
for /f "delims=" %%f in ('dir *.!ext! /a-d/s/b') do (
	set file=%%f
	for /f "tokens=1-5" %%a in ('timestomp "!file!" -v^|find "Modified"') do (
		if [%%a] == [Modified:] (
			set daystamp=%%b
			set datestamp=%%c
			set timestamp=%%d
			timestomp "!file!" -c "!daystamp! !datestamp! !timestamp!"
		)
	)
)

Open in new window

0
 
LVL 14

Expert Comment

by:Giovanni Heward
Comment Utility
Ah, too late.  :)
0
 

Author Comment

by:ddantes
Comment Utility
Thank you, and sorry that didn't appear sooner, in time to share points.
0
 
LVL 51

Expert Comment

by:Joe Winograd, EE MVE
Comment Utility
ddantes,
I don't mind at all sharing the points. Click Request Attention at the top and ask for the question to be re-opened. Then you may re-assign the points however you'd like. Regards, Joe
0
 

Author Comment

by:ddantes
Comment Utility
That's kind of you.  I'd like to award some points to the other Expert, because he invested time in developing an alternate solution.
0
 
LVL 51

Expert Comment

by:Joe Winograd, EE MVE
Comment Utility
Absolutely! I'm in complete agreement. It is the right thing to do. Regards, Joe
0
 

Author Comment

by:ddantes
Comment Utility
I've asked a moderator to reopen this question so that points can be shared.

Meanwhile, I posted a related question, and perhaps you could have a look...

http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Windows/Windows_7/Q_28301934.html
0
 
LVL 51

Expert Comment

by:Joe Winograd, EE MVE
Comment Utility
OK, the Moderators are usually fast to act...I'm sure it will be re-opened soon. In the meantime, I'll head over to your related question. Regards, Joe
0
 

Author Comment

by:ddantes
Comment Utility
Thank you.
0
 

Author Closing Comment

by:ddantes
Comment Utility
Thanks to both Experts.
0
 
LVL 14

Expert Comment

by:Giovanni Heward
Comment Utility
Your welcome, thanks for the points.  :o)
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

I found out last night windows update has a problem regarding 4 latest updates that fail.  The way to get all 4 them installed is install sp1 first and restart then one by one with a resart in between as they fail every time if all the four updates …
Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
This Micro Tutorial will teach you the basics of configuring your computer to improve its speed. It will also teach you how to disable programs that are running in the background simultaneously. This will be demonstrated using Windows 7 operating…
This Micro Tutorial will give you a introduction in two parts how to utilize Windows Live Movie Maker to its maximum editing capability. This will be demonstrated using Windows Live Movie Maker on Windows 7 operating system.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now