|
Ein Programm in der Programmiersprache | A program in the programming language | |||
vbScript | ||||
zur Änderung von Datum und Uhrzeit von Dateien per BASIC-Programm | for change of date and time of files per BASIC-program | |||
Datum und Uhrzeit einer Datei kann man mittels BASIC-Programmen auslesen, aber nicht verändern. Aber für alle gängigen Windows-Versionen gibt es ein Programm namens "FileTouch.exe", welches aus dem Internet herunter geladen und per Commando-Zeile aufgerufen werden kann. | Date and Time of a file can be read by BASIC-program, but not changed. But for all established windows-versions there is a program named "FileTouch.exe", which can be downloaded from internet and started per command-line call. | |||
Das Programm ist getestet vor der Publikation, aber es kann keine Garantie gegeben werden, dass es fehlerfrei ist | The program ist tested before publication, but there can be given no guarantee, that it is free of errors | |||
19. März 2014 | March 19th 2014 |
' The following mentioned properties of the file-object are all read-only Dim fso, f, s ' s = "dd.mm.yyyy hh:mm:ss" Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.GetFile(filespec) s = f.DateCreated ' read-only s = f.DateLastAccessed ' read-only s = f.DateLastModified ' read-only ' ------------- Program in vbScript for re-dating of a file ------------- Option Explicit ' causes error-msg if variable-declarations are forgotten Dim fso, WshShell, FileTouchSpec Set fso = CreateObject("Scripting.FileSystemObject") Set WshShell = CreateObject("WScript.Shell") FileTouchSpec = "d:\FileTouch.exe" ' FileTouch.exe downloaded from Internet SetDateAndTime "d:\TestFile.txt" ' Subcall Sub SetDateAndTime(AnyFileSpec) ' now = "dd.mm.yyyy hh:mm:ss" ' CmdLine = "FileTouch /D mm-dd-yyyy /T hh:mm:ss filename.ext" Dim CmdLine, DT, A If Not fso.FileExists(AnyFileSpec) Then Exit Sub If Not fso.FileExists(FileTouchSpec) Then Exit Sub DT = Split(Now," "): A = Split(DT(0),"."): DT(0) = Join(Array(A(1),A(0),A(2)),"-") CmdLine = Join(Array(FileTouchSpec,"/D",DT(0),"/T",DT(1),AnyFileSpec)," ") WshShell.Run CmdLine, 0, True End Sub | ||