How can I change the modified date of a .DBF file? In a daily run batch file, I want to take the same file that was created long time ago and then change its modified date to the current date so it won't display warning on the screen when processed in another program.
By copying, the creation date changes but not the modified date. The other program (fox something) seems to be eyeing only the modified date.
Thanks for the help.
Copy filename.dbf,,+
copy myfile,,+
=====================================
Helping others achieve escape felicityM2
Hi Wahine, Sorry, overlooked yours. [DOH]
=====================================
Helping others achieve escape felicityM2
Actually, I already saw that ",,+" in another question on txt file but somehow when I typed it myself it didn't work. So I thought it only works for txt files. Now that I copy&pasted your reply, it worked! Is there a magic trick somewhere? :D
Thanks!
How about if I want to date it as of yesterday?
Or, if it is not too much to ask, I want to date it as of the previous working day so that if today is monday, the file date will change to last friday.
Not obvious why it works pasted but not typed.
=====================================
Helping others achieve escape felicityM2
Quote=JMR: How about if I want to date it as of yesterday? Or, if it is not too much to ask, I want to date it as of the previous working day so that if today is monday, the file date will change to last friday.
I hope you're not gonna come up with any more surprises LOL.
The following batch script/VB script should do what you want but it does NOT cater for national or local holidays where if Friday is a hol it doesn't change the date to the previous working day and if Monday is a holiday, when the script is run on Tuesday the filedate will be changed to Monday. You must change the indicated line to reflect your filename. Not fully tested.
@echo off cls setlocal enabledelayedexpansion set vbs=%temp%\vbs.vbs > %vbs% echo WScript.Echo Date for /f "tokens=*" %%a in ('cscript //nologo %vbs%') do set savdate=%%a ( echo Newdate = Date echo Wn = DatePart("W" , Newdate^) echo Wscript.Echo Wn )>%vbs% FOR /F "tokens=1" %%A in ('cscript //nologo %vbs%') do ( set Weekday#=%%A ) If !weekday#! equ 1 set backdate=2&goto cont if !weekday#! equ 2 set backdate=3&goto cont set backdate=1 :cont > %vbs% echo WScript.Echo DateAdd("d",-%backdate%,Date) for /f "tokens=* delims=" %%a in ('cscript //nologo %vbs%') do set newdate=%%a del %vbs% :: Set filename to reflect YOURS :: ============================= :: Alter system date and file amended date echo %newdate% echo.|date> nul set filename=trial.bat copy %filename%,,+> nul :: Restore system date echo %savdate% echo.|date> nul dir %filename%Warning: During the few microseconds the date is changed to Newdate any file created/updated/accessed may show the date(s) as the Newdate. Also any program which uses the date (e.g. to name backups) could use the Newdate instead of the current date. Please check this out when testing the script.
Wish you good luckEdited to add warning and post updated script after some testing.
Thanks. But I don't exactly know where to put the file name in the script. I tried a few times and all I get is "no file found".
So here's the file and it's location. How does it fit in the script you generously wrote?
K:\Big Folder\small folder\file folder\datalocation\testing.dbf
Thanks.
OK, Try this: :: Alter system date and file amended date pushd k:\big folder\small folder\file folder\datalocation\ set filename=testing.dbf echo %newdate% echo.|date> nul copy %filename%,,+> nul :: Restore system date echo %savdate% echo.|date> nul dir %filename% popd
^ this one gave a result just like the ",,+" and not dated as today-minus-one. would it be easier, or is it possible, to "copy" the date modified of another file and apply that to the file I need?
p.s. thanks for your kindness
this one gave a result just like the ",,+" and not dated as today-minus-one. Then something failed without you noticing it. Should there be a space in datalocation?
Please post the script you are using.
Thanks for your help. I have decided to redate the file on the same day. I just have to do it at the end of the day. I think this is much better than waiting for the next day to redate it, especially because it will become more complicated when weekend and holidays come in between.
