Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2013-11-22
26
Medium Priority
?
1,843 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 12
  • 8
  • 5
26 Comments
 
LVL 15

Expert Comment

by:Giovanni Heward
ID: 39669968
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
ID: 39670050
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 15

Expert Comment

by:Giovanni Heward
ID: 39670057
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:ddantes
ID: 39670087
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 56

Accepted Solution

by:
Joe Winograd, EE MVE 2015&2016 earned 1600 total points
ID: 39670280
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
ID: 39670392
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 56

Expert Comment

by:Joe Winograd, EE MVE 2015&2016
ID: 39670406
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 56

Expert Comment

by:Joe Winograd, EE MVE 2015&2016
ID: 39670422
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
ID: 39670425
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 56

Expert Comment

by:Joe Winograd, EE MVE 2015&2016
ID: 39670431
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
ID: 39670433
Yes!  That did it.  Thank you for your help.
0
 

Author Comment

by:ddantes
ID: 39670436
Awesome solution!
0
 
LVL 56

Expert Comment

by:Joe Winograd, EE MVE 2015&2016
ID: 39670438
Excellent! You're very welcome.
0
 

Author Comment

by:ddantes
ID: 39670442
Thanks to both Experts who contributed.
0
 
LVL 15

Assisted Solution

by:Giovanni Heward
Giovanni Heward earned 400 total points
ID: 39670444
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 15

Expert Comment

by:Giovanni Heward
ID: 39670448
Ah, too late.  :)
0
 

Author Comment

by:ddantes
ID: 39670466
Thank you, and sorry that didn't appear sooner, in time to share points.
0
 
LVL 56

Expert Comment

by:Joe Winograd, EE MVE 2015&2016
ID: 39670486
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
ID: 39670557
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 56

Expert Comment

by:Joe Winograd, EE MVE 2015&2016
ID: 39670564
Absolutely! I'm in complete agreement. It is the right thing to do. Regards, Joe
0
 

Author Comment

by:ddantes
ID: 39670711
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 56

Expert Comment

by:Joe Winograd, EE MVE 2015&2016
ID: 39670768
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
ID: 39673170
Thank you.
0
 

Author Closing Comment

by:ddantes
ID: 39673171
Thanks to both Experts.
0
 
LVL 15

Expert Comment

by:Giovanni Heward
ID: 39709279
Your welcome, thanks for the points.  :o)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup" or a blinking cursor with black screen. A loop for Auto repair will start but fix nothing.  You will be panic as there are no backā€¦
On some Windows 7 (SP1) computers, Windows Update becomes super slow even the computer is reasonably fast.  There's one solution that seemed to have worked well for me (after trying a few other suggested solutions).
This Micro Tutorial will give you basic overview of the control panel section on Windows 7. It will depth in Network and Internet, Hardware and Sound, etc. This will be demonstrated using Windows 7 operating system.
This Micro Tutorial will go in depth within Systems and Security in Windows 7 and will go into detail regarding Action Center, Windows Firewall, System, etc. This will be demonstrated using Windows 7 operating system.
Suggested Courses

604 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