Batch for setting a file to 0byte

October 9, 2009 at 15:20:18
Specs: Windows XP
I look for a batch file which can set a file to 0 byte,while maintaining the creation timestamp. (mod time should be the time when set to zero).

I would like to use that for "deleting" movie/show stuff,so that way I can preserve the title(filename),time of download,and time of viewing(=time of "deletion").

One idea would have been to integrate this into the context menu so I can do this file by file.
Is it possible to hand over several filenames (%1;%2..) to a batch file,i.e. when I marked several files within the windows explorer and use a batch file from the context menu ?

additionaly if setting the filedate is not possible using just (xp build in) commandline tools,maybe nirCMD or fileTouch could be used ?
filetouch (tool for setting time/date ):
(http://www.softtreetech.com/24x7/archive/47.htm)


See More: Batch for setting a file to 0byte

Report •


#1
October 9, 2009 at 22:17:47
I put this in ZERO.BAT

@echo off > %1

It works on multiple files from the context menu.

BUT...

There's always a but part. LOL

This will give a new [current] mod date and keep the create date.

BUT when you copy or move you'll get a new create date.

:(


=====================================
Helping others achieve escape felicity

M2


Report •

#2
October 10, 2009 at 08:53:25
thanks a lot for the quick help!

I tried your way,BUT (yeah also a but :) ) I get a 0byte file where both dates (creation/mod) are changed to the current time/date :(


Report •

#3
October 10, 2009 at 10:01:24
It may be a difference between wk2 & XP. Beats me.


=====================================
Helping others achieve escape felicity

M2


Report •

Related Solutions

#4
October 11, 2009 at 16:52:41
this is not very elegant, but any consideration of just
recording the filenames in a file? Then, of course, you
have the botheration of having to view the file instead
of just looking at the directory listing. this batchfile
would maintain the list:

goto dd
1,5d
1,#s file(s)
.,#d
e
:dd
dir test*.* > list1
edlin list1 < d.bat
copy master + list1 master

this doesn't do the zeroing operation though,
but if you have a SEARCH command, it puts
C: in front of each filename, and you could
use edlin to make that listing into a batchfile
by replacing all C: with a copy (null file) or
echo > operation. and then save & execute
it as a batchfile.


Report •

#5
October 12, 2009 at 12:30:57
thanks for your answer !
Thats a good idea,not so messy as with all those 0byte files...

Report •


Ask Question