Modify file date and time

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Modify file date and time

Post by JRL » Mon Feb 19, 2007 7:25 pm

I had 29,000 CNC files that needed modification. I wrote a script that read each one line by line, made the appropriate changes and rewrote the files to a temporary location. My problem now is that the file dates on the original files go back 7 years and I need to modify the dates on the new files to match the dates on the old files.

I am aware of a third party program called "touch.exe" that can perform this operation but I'd rather not use a program that is not a part of the operating system or a part of Macro Scheduler. Ideally there is way to do this using a library function or a VB Script. I've been searching all morning and I've come up empty. Does anyone know of a way to modify a file's date and time using Macro Scheduler?

Thank you,
Dick

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Feb 19, 2007 7:59 pm

Should they all have the same date, or different dates?
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Mon Feb 19, 2007 8:02 pm

29,000 different dates and times.

Hope this makes sense.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Feb 19, 2007 8:12 pm

Do you still have the original unmodified files? I'm thinking of a workaround where your script would read the filedate/time of the original file, set the system date/time to the same date/time, then modify the file ... then move on to the next and repeat ...
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Mon Feb 19, 2007 8:18 pm

yes, still have the old files.
set the system date/time to the same date/time, then modify the file
I had thought about the same and that's what I intended to do if there was no magic way to get this done. If that is the best way then don't spend any more time on it. Just let me know its the only way and I'll manage.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Feb 19, 2007 9:10 pm

It might not be the only way, but I'm 99.9% certain there is no way to modify the file date with VBScript, and I'm not sure of any other way. It can probably be done with Win32 API but without further research I'm not sure of the details or whether it is something that MacroScript can handle.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Mon Feb 19, 2007 9:53 pm

Thank you Marcus. I appreciate your time and assistance.

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Tue Feb 20, 2007 1:45 am

Is it the created date, or last modified date that is the concern?

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Tue Feb 20, 2007 4:49 am

Last modified date. Do you have an idea?

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Tue Feb 20, 2007 3:42 pm

Yes I do, I think macroscheduler can do it, but it's a bit of a kluge that I hesitate to post here so I'll PM you :wink:

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts