Page 1 of 1 1
Topic Options
#199065 - 2010-07-22 08:25 AM Modify/Write Date Attribute on files
Arbracam Offline
Just in Town

Registered: 2008-04-21
Posts: 4
Hi everybody,

I would like to modify the date attribute (Date modification) of a video file.
I know the fonction "GETFILETIME ("file name", Mode)" returns the good date.
But I don't konw the fonction to modify this data. is it possible with kixstart?

Thx By advance.

Top
#199067 - 2010-07-22 09:43 AM Re: Modify/Write Date Attribute on files [Re: Arbracam]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
This UDF will modify the timestamp. There are a couple of caveats:
  • If the file doesn't exist you won't get an error.
  • For some reason relative paths seem to give the Shell.Namespace() method a problem, so use absolute paths for the file name


I'll leave these issues as an exercise for you to fix up.

In this example the modify timestamp on local file testfile.kix is set to the current time.

 Code:
Break ON
$=SetOption("Explicit","ON")

Dim $sFile
$sFile="testfile.txt"

$=SetFileTime($sFile,@DATE+" "+@TIME)
If @ERROR "Error setting time: ["+@ERROR+"] "+@SERROR+@CRLF EndIf

Function SetFileTime($sPath,$sDateTime)
	Dim $sDir,$sFile
	Dim $oShell,$oFolder

	$sFile=SubStr($sPath,InStrRev($sPath,"\")+1)
	If $sFile=$sPath
		$sDir=@CURDIR
	Else
		$sDir=Left($sPath,InStrRev($sPath,"\"))
	EndIf

	$oShell=CreateObject("Shell.Application")
	If @ERROR Exit @ERROR EndIf
	$oFolder=$oShell.NameSpace($sDir)
	If @ERROR Exit @ERROR EndIf
	$oFolder.Items.Item($sFile).ModifyDate=$sDateTime
	If @ERROR Exit @ERROR EndIf

	Exit 0
EndFunction

Top
#199068 - 2010-07-22 11:14 AM Re: Modify/Write Date Attribute on files [Re: Richard H.]
Arbracam Offline
Just in Town

Registered: 2008-04-21
Posts: 4
Thx a lot really for this quick answer.

No problem for the issue, For the first, I don't need to have a alert, and for the 2nd, I will find solution. \:\)

Now, I will can copy date attribute of my 500 files...

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 1172 anonymous users online.
Newest Members
StuTheCoder, M_Moore, BeeEm, min_seow, Audio
17884 Registered Users

Generated in 0.053 seconds in which 0.026 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org