[Batch] Lire heure minute + SECONDE fichier ?

Bonjour à tous ; s'il vous plaît :

En batch (".bat") avec du code vbs ou du code hexa pour echo cmd >> fichier.exe :

Comment s'il vous plaît récupérer à quelle seconde un fichier a été modifié ? Merci.

Et accessoirement, en batch (".bat") comment modifier la date d'un fichier ? Merci.

Pour les heures et les minutes, il y a des astuces mais pas pour avoir les secondes.

L'heure de création est utile mais plus pour quand j'utilise attribut changer 6 (ac.exe).

En général, je cale le temps sur le temps correspondant à la modification du fichier ...

Pouvoir générer un fichier exe en copiant du code hexa contenu dans le bat me plaît.
Cette idée et avec une amélioration de HexDump peut me servir ; merci beaucoup.
Faudrait pouvoir écrire ; merci de proposer une version modifiée depuis ce code.
http://www.richpasco.org/utilities/hexdump.html <= source et destination.

< config >Windows 7 / Firefox 3.6.26< / config >

2 réponses

  1. Contributeur
    hello
    avec les commandes Unix stat et touch, disponibles pour Windows là CoreUtils for Windows (prendre Binarires zip)
    C:> dir a 
    06/02/2012  13:46                24 a 
    C:> 
    C:> stat -c %y a 
    2012-02-06 13:46:35.031250000 +0100 
    C:> touch -m a 
    C:> dir a 
    13/02/2012  12:02                24 a 
    C:> stat -c %y a 
    2012-02-13 12:02:54.281250000 +0100 
    C:>
    1. slt : merci pour la réponse :)

      en fait, j'avais déjà cherché et trouvé cet outil, et je l'ai même téléchargé

      (C'est un outil externe et si il y a une astuce pratique pour l'encoder dans le bat, juste la ou les parties nécessaire, ça m'intéresse, comme du uuencode mais autoextractible.)

      j'ai vu du code vbs avec fso pour récupérer la date mais c'est pas facile

      Par-contre ; comment utiliser cela ; ça semble utile (j'avais demandé) :

      Quid avec des (plus) gros fichiers ? Comment sont codés les caractères ?
      Quid des codes spéciaux = comment ça marche avec ccm par exemple ?

      ÉDIT: Est-ce que c'est compatible pour écrire un octet dans n'importe quel fichier à un offset précis SANS CHARGER TOUT LE FICHIER EN MÉMOIRE ? fso comme javascript charge obligatoirement les fichiers en mémoire si j'ai bien compris ? Est-ce que ça peut être modifié (et comment) pour fonctionner comme un éditeur hexadécimal mais piloté par un fichier en ".bat" (c'est pas optimisé et c'est lent mais le but est que je puisse le faire un peu moi-même dans un premier temps ; ensuite faut booster à fond le code = besoin d'expert(s) en codage) ?

      Windows Script Host Examples (All) :
      http://www.robvanderwoude.com/wshexamples.php

      Convert a (small) binary file into VBScript code that can recreate that file

      http://www.robvanderwoude.com/files/bin2vbs_vbs.txt

      Option Explicit
      
      Dim i, intByte
      Dim objBinFile, objBinStream, objFSO, objScript
      Dim strBinFile, strFileExt, strFileName, strLine, strOut, strScriptVer
      
      strScriptVer = "1.00"
      
      Const ForAppending = 8
      Const ForReading   = 1
      Const ForWriting   = 2
      
      Const TristateFalse      =  0
      Const TristateMixed      = -2
      Const TristateTrue       = -1
      Const TristateUseDefault = -2
      
      Set objFSO = CreateObject( "Scripting.FileSystemObject" )
      
      With WScript.Arguments
      	If .Named.Count   > 0 Then Syntax
      	If .Unnamed.Count = 1 Then
      		strBinFile = .Unnamed(0)
      		If Not objFSO.FileExists( strBinFile ) Then Syntax
      	Else
      		Syntax
      	End If
      End With
      
      Set objBinFile   = objFSO.GetFile( strBinFile )
      Set objBinStream = objBinFile.OpenAsTextStream( ForReading, TristateFalse )
      strFileName = objFSO.GetBaseName( strBinFile )
      strFileExt  = objFSO.GetExtensionName( strBinFile )
      
      i = 0
      strOut = "Option Explicit" & vbCrLf _
             & "Dim objFile, objFSO" & vbCrLf _
             & "Const ForWriting = 2" & vbCrLf _
             & "Set objFSO = CreateObject( ""Scripting.FileSystemObject"" )" & vbCrLf _
             & "Set objFile = objFSO.CreateTextFile( """ & strFileName & "." & strFileExt & """, False, False )" & vbCrLf
      Do While Not objBinStream.AtEndOfStream
      	i = i + 1
      	If i = 10 Then
      		i = 0
      		strOut  = strOut & "objFile.Write" & Mid( strLine, 3 ) & vbCrLf
      		strLine = ""
      	End If
      	intByte = Asc( objBinStream.Read(1) )
      	strLine = strLine & " & Chr(" & intByte & ")"
      Loop
      objBinStream.Close
      Set objBinStream = Nothing
      Set objBinFile   = Nothing
      If strLine <> "" Then strOut = strOut & "objFile.Write" & Mid( strLine, 3 ) & vbCrLf
      strOut = strOut _
             & "objFile.Close" & vbCrLf _
             & "Set objFile = Nothing" & vbCrLf _
             & "Set objFSO = Nothing" & vbCrLf _
             & "WScript.Echo ""Created """"" & strFileName & "." & strFileExt & """""""" & vbCrLf
      
      Set objScript = objFSO.CreateTextFile( strFileName & ".vbs", False, False )
      objScript.Write strOut
      objScript.Close
      Set objScript = Nothing
      Set objFSO    = Nothing
      
      
      Sub Syntax( )
      ' Display help and, optionally, debugging information
      	WScript.Echo "Bin2Vbs.vbs,  Version " & strScriptVer & vbCrLf _
      	           & "Convert a (small) binary file to a script that can recreate that file" _
      	           & vbCrLf & vbCrLf _
      	           & "Usage:   BIN2VBS.VBS  binfile" _
      	           & vbCrLf & vbCrLf _
      	           & "Where:   ""binfile""    is the fully qualified path of the binary file" _
      	           & vbCrLf & vbCrLf _
      	           & "Result:  The VBScript file will be created in the current directory," _
      	           & vbCrLf _
      	           & "         with the NAME of the binary file, and extension "".VBS""" _
      	           & vbCrLf & vbCrLf _
      	           & "Written by Rob van der Woude" & vbCrLf _
      	           & "http://www.robvanderwoude.com"
      	WScript.Quit 1
      End Sub


      merci