Can someone suggest how I might be able to update the modification date of a
file to the current date & time without losing the content of the (binary)
file?

Thanks.

--Philip

Re: Change file's modification date? by McKirahan

McKirahan
Mon Oct 04 12:18:13 CDT 2004

"Philip Colmer" <pcolmer@newsgroups.nospam> wrote in message
news:OnaXaxiqEHA.896@TK2MSFTNGP12.phx.gbl...
> Can someone suggest how I might be able to update the modification date of
a
> file to the current date & time without losing the content of the (binary)
> file?
>
> Thanks.
>
> --Philip
>

Here's one way using the MS-DOS Copy command.

1) Create a 0-byte file:

rem>empty

2) Copy "empty" and your file into a new name:

copy empty+A.gif ~A.gif

3) Delete your file:

del A.gif

4) Rename the new file:

ren ~A.gif A.gif



Re: Change file's modification date? by Torgeir

Torgeir
Mon Oct 04 12:20:00 CDT 2004

Philip Colmer wrote:

> Can someone suggest how I might be able to update the
> modification date of a file to the current date & time
> without losing the content of the (binary) file?
>
> Thanks.
Hi

For Win2k and newer, this should work:

'--------------------8<----------------------
Set oShell= CreateObject("Wscript.Shell")
sPath = "C:\some path"
sFileName = "some file"

sCmd = "%comspec% /c cd /d " & sPath & " && " _
& "copy /b /y """ & sFileName & """ +,,"

oShell.Run sCmd, 0, True
'--------------------8<----------------------


--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx

Re: Change file's modification date? by Torgeir

Torgeir
Mon Oct 04 12:57:58 CDT 2004

McKirahan wrote:

> Here's one way using the MS-DOS Copy command.
>
> 1) Create a 0-byte file:
>
> rem>empty
>
> 2) Copy "empty" and your file into a new name:
>
> copy empty+A.gif ~A.gif
>
> 3) Delete your file:
>
> del A.gif
>
> 4) Rename the new file:
>
> ren ~A.gif A.gif
Hi

At least for Win2k and newer, you can avoid the temporary file
(the technique in the post in link below is also what I use in
the script in my other post in this thread):

http://groups.google.com/groups?threadm=e1veK9plEHA.2588%40TK2MSFTNGP12.phx.gbl


--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx

Re: Change file's modification date? by McKirahan

McKirahan
Mon Oct 04 13:27:58 CDT 2004

"Torgeir Bakken (MVP)" <Torgeir.Bakken-spam@hydro.com> wrote in message
news:uThIdvjqEHA.1152@TK2MSFTNGP11.phx.gbl...
> McKirahan wrote:
>
> > Here's one way using the MS-DOS Copy command.
> >
> > 1) Create a 0-byte file:
> >
> > rem>empty
> >
> > 2) Copy "empty" and your file into a new name:
> >
> > copy empty+A.gif ~A.gif
> >
> > 3) Delete your file:
> >
> > del A.gif
> >
> > 4) Rename the new file:
> >
> > ren ~A.gif A.gif
> Hi
>
> At least for Win2k and newer, you can avoid the temporary file
> (the technique in the post in link below is also what I use in
> the script in my other post in this thread):
>
>
http://groups.google.com/groups?threadm=e1veK9plEHA.2588%40TK2MSFTNGP12.phx.
gbl
>
>
> --
> torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
> Administration scripting examples and an ONLINE version of
> the 1328 page Scripting Guide:
> http://www.microsoft.com/technet/scriptcenter/default.mspx

You are correct; you'll be asked to Overwrite without a /y switch.

1) Create a 0-byte file:

rem>0

2) Copy "empty" and your file:

copy /b /y 0+ABC.gif

Previously I forgot the /b switch for binary files.



Re: Change file's modification date? by Dr

Dr
Tue Oct 05 09:27:07 CDT 2004

JRS: In article <OnaXaxiqEHA.896@TK2MSFTNGP12.phx.gbl>, dated Mon, 4
Oct 2004 17:08:11, seen in news:microsoft.public.scripting.vbscript,
Philip Colmer <pcolmer@newsgroups.nospam> posted :
>Can someone suggest how I might be able to update the modification date of a
>file to the current date & time without losing the content of the (binary)
>file?

In MSDOS, a file has a single date, shown by DIR; it is, barring tricks,
the date of last modification; it is the date most commonly shown in
Windows.

In Windows, files have more dates - creation date, write date, and
access date.

Reading changes the access date, writing might do so. Neither should
change the creation date.

You have asked to change the modification date, but not asked to change
the creation date; therefore, "solutions" presented should preserve the
creation date, or give you due warning.

A file might be on a floppy, or indeed a hard drive, and be larger than
the free disc space; in that case, any method based on copying will fail
(that might not *always* be the case, with modern Windows buffering).

The task is to change a few bits, no more than 64, in a directory entry;
even with modern Windows buffering, copying large files may be
perceptibly time-wasting, especially if processing many files or working
on a floppy.


There is a DOS utility called TOUCH (in many versions) which does just
what you want; I don't know what side-effects it may have on other
Windows dates; there may be a true Windows version. My own version is
DOSSTAMP, via sig line 3; it uses Borland Pascal SetFTime(F, LI) which I
assume to be a mere wrapper for Int 21/57.01 - see Ralf Brown's List.

There is, I suppose, a Windows API or suchlike to read/write all three
(and any other) datestamps; if no true WINTOUCH exists, perhaps some MVP
could write one?

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms & links.
PAS EXE TXT ZIP via <URL:http://www.merlyn.demon.co.uk/programs/00index.htm>.
Do not Mail News to me. Before a reply, quote with ">" or "> " (SoRFC1036)

Re: Change file's modification date? by Matthias

Matthias
Tue Oct 05 12:42:52 CDT 2004

Dr John Stockton wrote:

>JRS: In article <OnaXaxiqEHA.896@TK2MSFTNGP12.phx.gbl>, dated Mon, 4
>Oct 2004 17:08:11, seen in news:microsoft.public.scripting.vbscript,
>Philip Colmer <pcolmer@newsgroups.nospam> posted :
>>Can someone suggest how I might be able to update the modification date of a
>>file to the current date & time without losing the content of the (binary)
>>file?
>
>In MSDOS, a file has a single date, shown by DIR; it is, barring tricks,
>the date of last modification; it is the date most commonly shown in
>Windows.
>
>In Windows, files have more dates - creation date, write date, and
>access date.
>
>Reading changes the access date, writing might do so. Neither should
>change the creation date.
>
>You have asked to change the modification date, but not asked to change
>the creation date; therefore, "solutions" presented should preserve the
>creation date, or give you due warning.
>
>A file might be on a floppy, or indeed a hard drive, and be larger than
>the free disc space; in that case, any method based on copying will fail
>(that might not *always* be the case, with modern Windows buffering).
>
>The task is to change a few bits, no more than 64, in a directory entry;
>even with modern Windows buffering, copying large files may be
>perceptibly time-wasting, especially if processing many files or working
>on a floppy.
>
>
>There is a DOS utility called TOUCH (in many versions) which does just
>what you want; I don't know what side-effects it may have on other
>Windows dates; there may be a true Windows version. My own version is
>DOSSTAMP, via sig line 3; it uses Borland Pascal SetFTime(F, LI) which I
>assume to be a mere wrapper for Int 21/57.01 - see Ralf Brown's List.
>
>There is, I suppose, a Windows API or suchlike to read/write all three
>(and any other) datestamps; if no true WINTOUCH exists, perhaps some MVP
>could write one?
>
There are a lot, IMO originating in multi user os.

Here is one allowing to set given dates for c/w/a :

L:\Winstall\_TOOLS\AINTX>touch
Error: Usage: touch changes file time
Syntax: touch [-a time | -c time | -w time] -f filename
Switches
-a: change last access time where time is YYYYMMDDhhmmss
-c: change creation time
-f: file to change
-w: change last write time

http://www.dwam.net/docs/aintx/

HTH
--
Greetings
Matthias