#157208 - 2006-02-15 09:24 AM
Re: How to change a file date/time?
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Search around for a Windows port of "touch" - it is a command line program which originated on *nix systems but you will find DOS/Windows ports of it all over the place, and they are free.
It quite often comes in a "fileutils" package which includes many other utilities that make life so much easier.
One example is here: http://gnuwin32.sourceforge.net/packages/coreutils.htm
This package includes the following:
Quote:
File utilities: chgrp: Changes file group ownership. chown: Changes file ownership. chmod: Changes file permissions. cp: Copies files. dd: Copies and converts a file. df: Shows disk free space on filesystems. dir: Gives a brief directory listing. dircolors: Setup program for the color output of GNU ls. du: Shows disk usage on filesystems. install: Copies file and sets its permissions. ln: Creates file links. ls: Lists directory contents. mkdir: Creates directories. mkfifo: Creates FIFOs (named pipes). mknod: Creates special files. mv: Moves files. rm: Removes (deletes) files. rmdir: Removes empty directories. shred: Destroy data in files. sync: Synchronizes filesystem buffers and disk. touch: Changes file timestamps. vdir: Long directory listing. Text utilities: cat: concatenates and prints files on the standard output cksum: checksum and count the bytes in a file comm: compares two sorted files line by line csplit: splits a file into sections determined by context lines cut: remove sections from each line of files expand: convert tabs to spaces fmt: simple optimal text formatter fold: wrap each input line to fit in specified width head: output the first part of files join: join lines of two files on a common field md5sum: compute and check MD5 messsage digest nl: number lines of files od: dump files in octal and other formats paste: merge lines of files ptx: produce a permuted index of file contents pr: convert text files for printing shasum: compute and check SHA1 message digest sort: sort lines of text files split: split a file into pieces sum: checksum and count the blocks in a file tac: concatenates and prints files in reverse tail: outputs the last part of files tr: translates or deletes characters tsort: perform topological sort unexpand: convert spaces to tabs uniq: remove duplicate lines from a sorted file wc: prints the number of bytes, words, and lines in files Shell utilities: [ - Check file types and compare values basename - Removes the path prefix from a given pathname. chroot - Changes the root directory. date - Prints/sets the system date and time. dirname - Removes the last level or filename from a given pathname. echo - Prints a line of text. env - Displays/modifies the environment. expr - Evaluates expressions. factor - Prints prime factors. false - Returns an unsuccessful exit status. groups - Print the groups that the user is a member of. hostid - Print the numeric identifier for the current host hostname - Print or set the machine name. id - Print real/effective uid/gid. logname - Print current login name. nice - Modify scheduling priority. nohup - Allows a command to continue running after logging out. pathchk - Check file name portability. pinky - Lightweight finger printenv - Prints environment variables. printf - Formats and prints data. pwd - Print the current working directory. seq - Print numeric sequences. sleep - Suspends execution for a specified time. stty - Print/change terminal settings. su - Allows you to adopt the id of another user or superuser. tee - Sends output to multiple files. test - Evaluates an expression. true - Returns a successful exit status. tty - Print terminal name. uname - Print system information. users - Print current user names. who - Print a list of all users currently logged in. whoami - Print effective user id. yes - Print a string repeatedly.
If you only want a simple program without the install/DLL register hassle you will be able to find it with a little searching.
Update: I've just come across a comment that MS includes a port of TOUCH.exe in it's toolkits.
|
|
Top
|
|
|
|
#157209 - 2006-02-15 09:32 AM
Re: How to change a file date/time?
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Here is a link to a method using Shell.Application to set the date - I've not tried it so I can't comment further: http://msdn.microsoft.com/library/defaul.../modifydate.asp
|
|
Top
|
|
|
|
#157211 - 2006-02-16 11:26 AM
How to change a file date/time: the answer
|
Flavien
Getting the hang of it
Registered: 1999-07-21
Posts: 95
Loc: Geneva, Switzerland
|
Voilà, this works:
Code:
;ModifyFileDate - Modify a file date and time. Function ModifyFileDate($file, Optional $date) ;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/objects/folderitem/modifydate.asp ;Quick and dirty function, the $date format depends on the local settings, ;but this works when we need to re-apply the same date after having modified a file. Dim $object, $file_path, $file_name, $object_path, $folder_item $file_path = SubStr($file, 1, InStrRev($file, "\") - 1) $file_name = SubStr($file, InStrRev($file, "\") + 1) $object = CreateObject("Shell.Application") $object_path = $object.NameSpace($file_path) If $object_path <> "" $folder_item = $object_path.ParseName($file_name) If $folder_item <> "" $ModifyFileDate = $folder_item.ModifyDate If IsDeclared($date) $folder_item.ModifyDate = $date EndIf EndIf EndIf EndFunction
I'm too lazy to put it in the UDF section...
|
|
Top
|
|
|
|
#157213 - 2006-02-16 12:53 PM
Re: How to change a file date/time: the answer
|
Flavien
Getting the hang of it
Registered: 1999-07-21
Posts: 95
Loc: Geneva, Switzerland
|
Mart, this is a valid point, I've been wondering if someone would first ask me the purpose of my initial request...
A good use of this would be, for example, this Office 2000 problem: Full-file version update may request Office source files http://support.microsoft.com/kb/840169/
Another usage is for doing a mass modification of many user's documents. When doing so, suddendly the user would believe her files were all messed up, and would certainly confuse the result of a file search.
|
|
Top
|
|
|
|
#206919 - 2013-03-14 10:49 PM
Re: How to change a file date/time: the answer
[Re: Lonkero]
|
Allen
KiX Supporter
   
Registered: 2003-04-19
Posts: 4572
Loc: USA
|
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 661 anonymous users online.
|
|
|