Source language: Translate to:

HpwIPTC change the file date

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

HpwIPTC change the file date

Postby dickvanrijn » Sun Feb 04, 2007 2:38 pm

is it possible to correct the file date -which the explorer shows - within NB? HpwIPTC change the date with updating the IPTC information. Any idea? Thank you
User avatar
dickvanrijn
 
Posts: 15
Joined: Thu Feb 01, 2007 10:42 am
Location: Germany

Postby Sam Cox » Sun Feb 04, 2007 6:56 pm

Each file in a Window file system has three dates: Created, Accessed, and Modified. I think the date you're referring to is the Modified date.

Linux and other Unix-like systems have the "touch" function to update the Unix equivalent of the Modified date. Windows does not provide that function, but there are downloadable utilities that will "touch" files for you.

Neobook does not provide a TouchFile command (but that would be a nice addition to the command set), but we can write our own.

Attempt #1:
Code: Select all
SetVar "[File]" "C:\path\filename.txt"
FileRead "[File]" "1" "[Line]"
Filewrite "[File]" "1" "[Line]"

This works for text files and is very quick. It works by reading the first line of the file and then updating the file with that same line. The only noticable change is that the Modified date is updated. Another change that you will probably not notice is that the file is written to a different physical location on your disk drive.

Attempt #2:
Code: Select all
SetVar "[File]" "C:\path\filename.ext"
FileRead "[File]" "all" "[All]"
Filewrite "[File]" "all" "[All]"

This works for any file but is not as quick as Attempt #1. It works by reading the entire file into variable [All], and then rewriting the entire file. Again, the only noticable change is that the Modified date is updated. I used Attempt #2 to change the Modified dates of several *.jpg files. It seems to work quite well.

Both versions as well as most "touch" utilities will fail with Read-Only files as well as with files on non-writable media such as CD-ROMs. Moreover, files that you do not have permission to update such as files belonging to the System Administrator or files that are currently locked by other applications or by the operating system cannot be updated.
User avatar
Sam Cox
 
Posts: 768
Joined: Fri Apr 01, 2005 7:30 am
Location: Loveland CO USA

Postby HPW » Sun Feb 04, 2007 11:34 pm

is it possible to correct the file date -which the explorer shows - within NB? HpwIPTC change the date with updating the IPTC information. Any idea? Thank you


hpwIPTC changes the file so it is correct to set the modified date.
I think he want to get back the old date.
So he needs 2 functions: One to read the date before modifing and one for reseting the date to the stored dated.
Hans-Peter
User avatar
HPW
 
Posts: 2510
Joined: Fri Apr 01, 2005 11:24 pm
Location: Germany

iptc reset the modified date of the JPGs

Postby dickvanrijn » Mon Feb 05, 2007 4:51 am

HPW is right:

hpwIPTC changes the file so it is correct to set the modified date.
I think he want to get back the old date.
So he needs 2 functions: One to read the date before modifing and one for reseting the date to the stored dated


I´ve stored the date before modifing in IPTC. How do I reset the modified date of the JPGs (no text)? Thanks!
User avatar
dickvanrijn
 
Posts: 15
Joined: Thu Feb 01, 2007 10:42 am
Location: Germany

Postby HPW » Mon Feb 05, 2007 5:01 am

You may have a look at rtSetFileDate from rtFileSystemMgt:

http://www.ronmarie.com/rt_fsm.html
Hans-Peter
User avatar
HPW
 
Posts: 2510
Joined: Fri Apr 01, 2005 11:24 pm
Location: Germany

Postby eb » Mon Feb 05, 2007 5:15 pm

You can also do it with NirCmd, a command-line tool posted before on forums:

http://www.neosoftware.com/forum/viewtopic.php?t=14354

web: http://www.nirsoft.net/utils/nircmd.html

Freeware and only 25Kb.

From NirCmd help file:

setfiletime [filename or wildcard] [Created Date] {Modified Date} {Accessed Date}
Changes the Created/Modified/Accessed date of one or more files. The first parameter can be a single filename or wildcard string. The dates parameters must be specified in the following format: "dd-mm-yyyy hh:nn:ss" if a date parameter is not specified or you specify an empty string (""), the date won't be changed. If you specify "now" as date parameter, the current date and time will be used
Examples:
setfiletime "c:\temp\*.exe" "15-05-2004 11:22:12" "22-01-2005 21:22:55"
setfiletime "c:\temp\myfile.txt" "24-06-2003 17:57:11" "" "22-11-2005 10:21:56"
setfiletime "c:\temp\myfile.txt" now now


You can run nircmd with neobook Run function:

Code: Select all
Run "[pundir]nircmdc.exe" "setfiletime [#34]test.txt[#34] [#34]15-01-2007 11:22:12[#34]" "RunOnce+Wait+Hidden" "" ""


As Hans say, take a look at rtFileSystemMgt, a very interesting plugin.
eb
 
Posts: 4
Joined: Thu Jul 06, 2006 1:28 pm

change date

Postby dickvanrijn » Tue Feb 06, 2007 5:08 am

thank you guys!
User avatar
dickvanrijn
 
Posts: 15
Joined: Thu Feb 01, 2007 10:42 am
Location: Germany


Return to NeoBook Action Commands

Who is online

Users browsing this forum: No registered users and 1 guest